Home >Backend Development >PHP Tutorial >stripslashes() function and addslashes() function in PHP
This article will introduce you to the stripslashes() function and addslashes() function in PHP.
Definition and usage
The stripslashes() function deletes the backslashes added by the addslashes() function Backslash.
Tip: This function can be used to clean data retrieved from the database or from an HTML form.
<?php echo stripslashes("Who\'s Bill Gates?");
Definition and usage
## The #addslashes() function returns a string with a backslash added before the predefined characters. The predefined characters are: single quote (') double quote ( ") Backslash (\) NULLTip: This function can be used to prepare characters for strings stored in the database and database query statements string.
Note: By default, PHP automatically runs addslashes() on all GET, POST, and COOKIE data. So you should not use addslashes() on already escaped strings, as this will result in double escaping. When encountering this situation, you can use the function get_magic_quotes_gpc() to detect it.
<?php $str = addslashes('Shanghai is the "biggest" city in China.'); echo($str);
PHP Chinese website!
The above is the detailed content of stripslashes() function and addslashes() function in PHP. For more information, please follow other related articles on the PHP Chinese website!