addslashes
addslashes
Quote string with slashes
string **addslashes** string $string
Returns a string with backslashes added before characters that need to be escaped. These characters are:
'``"``\
A use case of is escaping the aforementioned characters in a string that is to be evaluated by PHP:
addslashesVoorbeeld: Escaping Characters
<?php
$str = "O'Reilly?";
eval("echo '" . addslashes($str) . "';");
?>
The is sometimes incorrectly used to try to prevent
. Instead,
database-specific escaping functions and/or prepared statements should be used.
addslashesSQL Injection
stringThe string to be escaped.
Returns the escaped string.
Voorbeeld: An example
<?php
$str = "Is your name O'Reilly?";
// Outputs: Is your name O\'Reilly?
echo addslashes($str);
?>
stripcslashes``stripslashes``addcslashes``htmlspecialchars``quotemeta``get_magic_quotes_gpc