In PHP, you can use the stripslashes function to remove escape characters in json data. The syntax of this function is "stripslashes(string)", and its parameter string represents the string to be checked.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How to remove escape characters from php json?
php has a way to handle escape characters when accepting json data
Because data transmission is almost always in json format, and when converting data When it is converted into json, it is usually escaped. At this time, if you directly use the json_decode function to process the received json data, the system will definitely report an error because it cannot be converted, and the processing method is also very simple, that is, convert the json data in Just remove the escape characters. PHP has a function stripslashes() that does this. Its function is to delete the backslashes added by the addslashes() function; of course, this function can remove the backslashes in the string. of.
Related function introduction:
The stripslashes() function is used to remove 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.
Syntax
stripslashes(string)
Parameters
string Required. Specifies the string to check.
Return value: Returns the string with backslashes stripped.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to remove escape characters in php json. For more information, please follow other related articles on the PHP Chinese website!