Home > Article > Backend Development > How to use php quotemeta function
php quotemeta function represents the escape metacharacter set. The syntax of quotemeta is quotemeta(string). The parameter string is required and is the string that needs to be processed.
php How to use quotemeta function?
Function: Add a backslash before the predefined characters
Syntax:
quotemeta(string)
Parameters:
string Required, characters that need to be processed String
Description: This function can be used to escape characters with special meanings, such as ( ), [ ] and * in SQL. This function is binary safe.
php quotemeta() function usage example:
<?php $str1 = "1 + 1 = 2"; $str2 = "1 * 1 = 1"; $str3 = "Welcome to php.cn!"; $str4 = "Are you ok?"; echo quotemeta($str1)."<br>"; echo quotemeta($str2)."<br>"; echo quotemeta($str3)."<br>"; echo quotemeta($str4)."<br>"; ?>
Output:
1 \+ 1 = 2 1 \* 1 = 1 Welcome to php\.cn! Are you ok\?
This article is an introduction to the PHP quotemeta function. I hope it will help you if you need Friends help!
The above is the detailed content of How to use php quotemeta function. For more information, please follow other related articles on the PHP Chinese website!