Home > Article > Backend Development > PHP function stripslashes() that removes backslashes added by addslashes() function
Example
Remove Backslash:
<?php echo stripslashes("Who's Peter Griffin?"); ?>
Definition and usage
stripslashes() function is deleted by addslashes () The backslash added by the function.
Tip: This function can be used to clean data retrieved from the database or from an HTML form.
Syntax
stripslashes(string)
Parameters | Description |
string | Required. Specifies the string to be checked |
Technical details
Return value: | Returns the string with backslashes stripped. |
PHP version: | 4+ |
##By default, the PHP command magic_quotes_gpc is on , automatically runs addslashes() on all GET, POST and COOKIE data. This is for database security. Some characters are unsafe to store directly in the database. They are: Single quote (')
Double quote (")
Backslash (\)
NULL
*** *************************************************** *************************************************** *******
addslashes() function adds a backslash before the specified predefined characters. These predefined characters are:
Single quote (')
Double quote (") ##. #Backslash(\)
NULL
************************************ *************************************************** ************************
<?php
$str = "Who's John Adams?";
echo $str . " This is not safe in a database query.<br />";
echo addslashes($str) . " This is safe in a database query.";
?>
Who's John Adams? This is not safe in a database query.
Who\'s John Adams? This is safe in a database query.
stripslashes() function is the reverse of addslashes() Action, that is: remove the backslashes added by the addslashes() function. **************************************************** *************************************************** *************
stripslashes() Example: <?php
echo stripslashes("Who\'s John Adams?");
?>
Who's John Adams?
The above is the detailed content of PHP function stripslashes() that removes backslashes added by addslashes() function. For more information, please follow other related articles on the PHP Chinese website!