Showing posts with label PHP quotemeta. Show all posts
Showing posts with label PHP quotemeta. Show all posts

Monday, 29 September 2014

quotemeta in PHP

PHP quotemeta() function is utilized to include backslash character( \ ) before some predefined characters in a string.

The predefined characters are :

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

quotemeta(string)
string : Required.  Defines the input string.   

Tip: This function might be utilized to escape with special meaning, for example (), [], and * in SQL.

Example:

<?php
$input_str  = "Good Morning. (what are you doing?)";
echo quotemeta ($input_str);
?>
The output  will be:
Good Morning\. \(what are you doing\?\)