Home >>PHP String Functions >PHP quotemeta() Function
PHP quotemeta() function is used to add a backslash before some predefined meta characters in the string. This function accepts a string as an argument and returns the string by adding the backslash before every predefined meta characters. By using this function we can avoids SQL injections attacks to our database. This function is also binary safe, which means it can be executed on a binary file without making any changes in it.
Some of the predefined meta characters are:
Syntax:
quotemeta($string);
Parameter | Description |
---|---|
string | This ia the required parameter. This parameter contains the input string to be checked. |
Here is an example of quotemeta() function in PHP:
<html> <body> <?php echo quotemeta("Hey Everyone..."); ?> </body> </html>
Here is an another example of quotemeta() function in PHP:
<html> <body> <?php $str1 = "You + Me"; $str2 = "**PHP**"; $str3 = "PHP or Python??"; $str4 = "Can you give me $100"; $str5 = "Only Jerry(Admin) can login to this site."; echo quotemeta($str1)."<br>"; echo quotemeta($str2)."<br>"; echo quotemeta($str3)."<br>"; echo quotemeta($str4)."<br>"; echo quotemeta($str5)."<br>"; ?> </body> </html>