Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP quotemeta() Function

PHP quotemeta() Function

PHP String Reference Manual PHP String Reference Manual

Example

Add backslashes before predefined characters:

Run Example »


Definition and Usage

The quotemeta() function adds backslashes before certain predefined characters in a string.

The predefined characters:

**Tip:** This function can be used to escape characters with special meaning, such as ( ), [ ] and * in SQL.

**Note:** This function is binary-safe.


Syntax

quotemeta(

string

)

Parameters Description
string Required. Specifies the string to check.

Technical Details

Return Value: Returns the string with quoted metacharacters.
PHP Version: 4+

More examples

Example 1

Add backslashes before multiple predefined characters:

"; echo quotemeta($str2)."
"; echo quotemeta($str3)."
"; echo quotemeta($str4)."
"; echo quotemeta($str5)."
"; ?>

Run Example »


PHP String Reference Manual PHP String Reference Manual