PHPJSON resolution solution

Source: Internet
Author: User
Tags php json
PHPJSON parses up_user_info {name: liux, sex: 1, phone: 13712800254, email: [email & #160; protected], town: town_1, age: 18, heweigh: 180, experience: Work experience} $ up_user_info php json parsing
Up_user_info = {"name": "liux", "sex": "1", "phone": "13712800254", "email": "[email protected]", "town": "town_1", "age": "18", "heigh": "180", "experience": "work experience "}

$ Up_user_info = $ _ POST ['up _ user_info '];
If ($ up_user_info = null ){
$ Error = 1;
}
$ Upuser_decode = json_decode ($ up_user_info, true );
$ Name = $ upuser_decode ['name'];


Echo $ name;


The output is null ~~ Why? I don't know what's wrong if I want to try it!
------ Solution --------------------
$ _ POST ['up _ user_info '] =' {"name": "liux", "sex": "1", "phone": "13712800254 ", "email": "[email protected]", "town": "town_1", "age": "18", "heigh": "180", "experience ": "Work experience "}';
Print_r (json_decode ($ _ POST ['up _ user_info ']); is it null?

It means that you are in the gbk environment
Print_r (json_decode (iconv ('gbk', 'utf-8', $ _ POST ['up _ user_info ']);
You can.
StdClass Object
(
[Name] => liux
[Sex] => 1
[Phone] = & gt; 13712800254
[Email] => [email protected]
[Town] => town_1
[Age] => 18
[Heigh] => 180
[Experience] => work experience
)


------ Solution --------------------
You can perform this operation
1. $ up_user_info is post
2. use the program above

Whether the partition can be detached or not.

If 1 cannot be 2, there is a problem with the POST data. Please check the data here.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.