Home > Backend Development > PHP Tutorial > Analyze the differences and comparisons between php addslashes() and addclashes() functions_PHP tutorial

Analyze the differences and comparisons between php addslashes() and addclashes() functions_PHP tutorial

WBOY
Release: 2016-07-21 15:03:52
Original
821 people have browsed it

PHP addcslashes() function
Definition and usage
addcslashes() function adds a backslash before the specified character.
Syntax
addcslashes(string,characters) Parameter Description
string Required. Specifies the string to check.
characters optional. Specifies the characters or range of characters affected by addcslashes().
Tips and Notes
Note: Be careful when applying addcslashes() to 0, r, n and t. In PHP,
And the usage of function addslashes():

PHP addslashes() function
Definition and usage

addslashes() function specifies predefined characters Add a backslash before.
These predefined characters are:

• Single quote (')
• Double quote (")
• Backslash () • NULL

Syntax

addslashes(string) Parameter Description

string Required. Tips and Comments
Tip: This function can be used. Prepare appropriate strings for strings stored in the database and database query statements.

Note: By default, the PHP directive magic_quotes_gpc is on, automatically running addslashes() on all GET, POST and COOKIE data. . Do not use addslashes() on strings that have been escaped by magic_quotes_gpc, because this will cause double-level escaping. You can use the function get_magic_quotes_gpc() to detect this situation. Example

In this example, we want to add a backslash to a predefined character in a string:
$str = "Who's John Adams?";
echo $str . " This is not safe in a database query.
";
echo addslashes($str) . " This is safe in a database query.";
?>
Output:
Who's John Adams? This is not safe in a database query. The backslash methods are: stripcslashes() and stripslashes().


http://www.bkjia.com/PHPjc/327816.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/327816.html
TechArticle

PHP addcslashes() function definition and usage addcslashes() function adds a backslash before the specified character. Syntax addcslashes(string,characters) Parameter Description string Required. It is stipulated to check...




source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template