PHP quotemeta() Function


The quotemeta() is an in-built function of PHP,is used to adds backslashes before some predefined characters in a string.

The pre-defined meta characters
  • Period Plus (.)
  • backslash (\)
  • Plus(+)
  • Asterisk (*)
  • Question mark (?)
  • Square Brackets ([])
  • Caret (^)
  • Dollar ($)
  • Parenthesis (())
Syntax
quotemeta(string)
Parameters
  • string - (Required) Specify the string to check.
Example
<?php
   $a = "Hello Students. (please listen me.)";
   echo quotemeta($a);
?>

Output

Hello Students\. \(please listen me\.\)

Prev Next