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.