📅  最后修改于: 2023-12-03 15:35:10.296000             🧑  作者: Mango
Stripslash is a built-in PHP function that removes backslashes () from a string. It is commonly used to remove slashes added by magic quotes.
stripslashes ( string $str ) : string
Returns the string with backslashes removed.
$string = "This is a \test";
echo "Original string: " . $string . "<br>";
echo "After removing backslashes: " . stripslashes($string);
Output:
Original string: This is a \test
After removing backslashes: This is a test
When using form input, magic quotes can automatically add backslashes to input fields. Stripslash can be used to remove these backslashes.
$input = $_POST['input_field'];
$clean_input = stripslashes($input);
echo "Cleaned input: " . $clean_input;
Stripslash is a useful built-in function in PHP for removing backslashes from strings. It is commonly used in form input handling to remove slashes added by magic quotes.