PHP addslashes () and Stripslashes () implement string escape and restore usages, use of escape characters
Examples in this article describe the use of addslashes () and stripslashes () in PHP for string escaping and restoration. Share to everyone for your reference, as follows:
The addslashes () function in PHP returns a string that adds a backslash before a predefined character.
The predefined characters are:
Single quotation mark (')
Double quotation marks (")
Back slash (\)
Null
the Stripslashes () function deletes a backslash added by the addslashes () function .
The usage examples are as follows:
<?php $str = "Select * from ' book ' where Bookname= ' house of Help '"; echo $str. "
";//output String $str echo $astr =addslashes ($STR);//string escape and Output echo"
"; echo stripslashes ($ASTR);//Will escape string restore?>
The results of the operation are as follows:
SELECT * from ' book ' Where Bookname= ' home ' select * from ' book ' where bookname=\ ' help home \ ' select * from ' book ' where bookname= ' Home for the guests '
Add:
Addslashes () differs from the Addcslashes () function:
This is two very similar. but using a different function, the addslashes () function returns a string that adds a backslash before the predefined character, and the Addcslashes () function returns a string that adds a backslash before the specified character, so addcslashes () The function needs to add additional parameters that describe the specific characters that need to be added with backslashes.
The two specific differences and usage can refer to the relevant articles of this site "parsing PHP addslashes () and addcslashes () functions of the difference and comparison"
I hope this article is helpful to you in PHP programming.
Articles you may be interested in:
- addslashes function and SQL anti-injection in PHP
- Analysis of security principle of using addslashes function escaping in PHP
- PHP explanations for Htmlspecialchars, Strip_tags, addslashes
- The difference between PHP functions Addslashes and mysql_real_escape_string
- The difference between PHP stripslashes and addslashes
- Parsing the differences and comparisons between PHP addslashes () and addclashes () functions
- What are the different analyses of PHP daddslashes () and saddslashes ()?
- PHP addslashes and other ways to clear the space are unsafe
- PHP addslashes and Mysql_real_escape_string
- PHP addslashes function Detailed Analysis description
- Analysis of addcslashes and stripcslashes function usage in PHP
http://www.bkjia.com/PHPjc/1089584.html www.bkjia.com true http://www.bkjia.com/PHPjc/1089584.html techarticle php addslashes () and stripslashes () implement the string escape and restore usages instance, the use of escape characters in this article describes PHP addslashes () and stripslashes () to implement the string escape and ...