PHP string quotemeta() function
The quotemeta() is an in-built function of PHP, which is used to add a backslash before some meta characters in the string. It returns the string by adding the backslash before every meta characters. It avoids SQL injections attacks of our database. The quotemeta() is a binary-safe function, means that type of function which can be executed on a binary file without modifying its content.
The predefined meta character are:
Note: This function can be used to escape the character with special meaning.
The syntax for the quotemeta() function is given below, which has only one string parameter:
String (required) - This function has a single parameter, which is string. We provide string parameter in this function to quote backslash before every meta character which is listed above in the tutorial.
The quotemeta() function returns the string by adding the backslash (\) before every meta character which is listed above or return FALSE if the given string is empty.
To understand the practical implementation of the quotemeta() function, see the examples which are given below:
Let's check the below output to see that backslash is added in front of every meta character.
Hello user! Welcome to javaTpoint\. Would you like to learn PHP\?
Let's check the below example that backslash (\) is added before every meta character.
Dollar symbol \$ is used to declare variable in PHP\. Matrix is represented by square \[\ ] brackets\.
equation1 =/(m - n/) /^o /* p