Home  >  Article  >  Backend Development  >  How to use php quotemeta function

How to use php quotemeta function

藏色散人
藏色散人Original
2019-01-31 10:07:531974browse

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.

How to use php quotemeta function

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn