PHP removes the backslash in the json string and the backslash before the double quotation marks. json double quotation marks. PHP removes the backslash in the json string and the backslash before the double quotation marks. json double quotation
IntroductionIn the field of business, to customer deployment projects, three projects to be integrated together, which results in different data formats, the path of the slash and backslash caused a lot of problems.Check out this information, here
The server space provided by the general Space quotient default PHP directive MAGIC_QUOTES_GPC is on, that is, open. You can then use the stripslashes () function to remove the auto-added backslash. The usage is: for example, the variable containing
This article describes how to remove backslashes from json strings in PHP and the backslashes before double quotation marks in PHP. For more information, see
This article describes how to remove the backslash \ from the json string in PHP and the
PHP extension text processing -- PCRE regular expression syntax 3 -- escape sequence (backslash) backlash has multiple usage. First, if it is followed by a non-alphanumeric character, it indicates that the special meaning represented by this
The JSON string that is passed to PHP via Ajax is sometimes added with a backslash "\" to escape, and PHP needs to be stripped of the backslash before Json_decode.
ps:php get fetch JSON how to remove backslash before double quotation mark
The JSON string that is uploaded to Php via Ajax is sometimes added with a backslash "\" to escape, and the PHP process needs to remove the backslash first and then Json_decode.
$str = stripslashes ($_post[' json '));
Ps:php get crawl JSON
Instance
Add a backslash before each double quotation mark ("):
Definition and usage
The Addslashes () function returns a string that adds a backslash before a predefined character.
The predefined characters are:
Single quotation mark (')
Double
What is Magic Quotes
When turned on, all ' (single quotes), "(double quotes), \ (backslash), and NULL characters are automatically added with a backslash to escape. This is exactly the same as the addslashes () function.
A total of three magic
Add a backslash (php removes the backslash) before the PHP quotes.
$ Str = $ _ POST ["str"]; // read the str content and assign it to the $ str variable.
If (get_magic_quotes_gpc () {// if get_magic_quotes_gpc ()
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.