quote_meta

The quotemeta() function adds backslashes in front of some predefined characters in a string.

This function can be used to escape characters with special meanings, such as ( ), [ ], and * in SQL.

This function is binary-safe.

The predefined characters are:

  • period (.)
  • backslash (\)
  • plus sign (+)
  • asterisk (*)
  • question mark (?)
  • brackets ([])
  • caret (^)c
  • dollar sign ($)
  • parenthesis (())

Example

<?php
 $str = "PHP Codez. (Welcome)";
 echo quotemeta($str);
?>

It outputs PHP Codez\. \(Welcome\)

Share

One thought on “quote_meta”

  1. Pingback: Google

Leave a Reply

Your email address will not be published. Required fields are marked *