Home > Article > Backend Development > How to remove backslash in php
How to remove backslashes in php: First open the corresponding PHP file; then remove the backslashes through the "stripslashes($_POST['json']);" method.
Recommended: "PHP Video Tutorial"
PHP removes backslashes in json strings \
The json string passed to PHP through AJAX is sometimes escaped with a backslash "\". During PHP processing, the backslash needs to be removed first and then json_decode.
$str = stripslashes($_POST['json']); $arr = json_decode($str,true);
Related introduction:
stripslashes() function removes the backslashes added by the addslashes() function.
Tip: This function can be used to clean data retrieved from the database or from an HTML form.
Grammar
stripslashes(string)
The above is the detailed content of How to remove backslash in php. For more information, please follow other related articles on the PHP Chinese website!