Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of transferring JSON string to background PHP

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how to solve the problem of passing JSON strings to background PHP. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

During the development of the project, because it involves the input of the batch record array, and because of the large number of fields, it is impossible to transmit it in the ordinary way & a=322&=gsd&v=rwe. So I think of the front-end transmission of JSON format in the past content= [{'axiafiughuo 2321, gsdling, gsdling, gsd4, gsd2, etc.]. In this way, it is also very convenient to parse multiple records in the background. But when I sent this message, the backstage received [{\ a\': 2321,\'b\':\ 'gsd\',\'c\':\ 'dww\'}.] This format, and I need the standard JSON format string, using PHP json_decode parsing directly converted into an array, so I easy to operate, to the Internet to search a lot of students also encountered the same problem as me, looking for a long time the best still can not find the answer, and finally out of their own, stripslashes uses this function in PHP, the obtained JSON string conversion will be OK

In fact, this problem is caused by the get_magic_quotes_gpc () function, which should not be a problem if the configuration in php.ini is off, so add judgment when using this function.

/ / $json is the received JSON string if (get_magic_quotes_gpc () = = 1) {$json = stripslashes ($json);} Thank you for reading! This is the end of this article on "how to solve the problem of sending JSON strings to the background PHP processing". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report