quotemeta – PHP String Functions
Syntax :
Description :
The quotemeta() function adds backslashes in front of below characters.
The predefined characters are:
period (.)
backslash (\)
plus sign (+)
asterisk (*)
question mark (?)
brackets ([])
caret (^)
dollar sign ($)
parenthesis (())
Parameter :
[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|lef|lef|left”]
Name, Required /Optional, Value Type, Description
string , Required, String , It is the input string.
[/table]
Output :
Returns the string with meta characters quoted, or FALSE if an empty string is given as string.
Related articles : htmlspecialchars_decode() ,nl2br() , stripslashes() , stripcslashes() , quoted_printable_encode() , addslashes() , addcslashes() , htmlentities() , htmlspecialchars().
quotemeta() – PHP Functions Example 1 :
<?php $str = "Hi All. Thanks for reading my tutorials+!."; echo quotemeta($str); ?>
Output of above code in the browser is as below:
quotemeta() – PHP Functions Example 2 :
<?php $strEg1 = "2 + 2 = 4"; $strEg2 = "3 * 2 = 6"; $strEg3 = "How are you?"; $strEg4 = "Are you Fine? (Yes, I am..)"; $strEg5 = "The caret [ ^ ] Looks like a hat!"; echo quotemeta($strEg1)."\n"; echo quotemeta($strEg2)."\n"; echo quotemeta($strEg3)."\n"; echo quotemeta($strEg4)."\n"; echo quotemeta($strEg5)."\n"; ?>
Output of above code in the browser is as below:
3 \* 2 = 6
How are you\?
Are you Fine\? \(Yes, I am\.\.\)
The caret \[ \^ \] Looks like a hat!