This article brings you an introduction to the method of uploading json files in PHP (code examples). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
HTTP: A hypertext transmission protocol. It is a standard protocol for computer-to-computer communication. It is now generally used for end-to-end communication.
1. Agreed content
Request/response message format
Request method GET/POST
Response status 200/404/302/304
Default request/response header
The header function in PHP is used to set the response header
Supplement:
The client browser will automatically Jump to the specified address
JSON
JSON: A means of expressing data similar to js literals
The attribute name in JSON must be Use double quotes
Strings in JSON must use double quotes (js strings can use single quotes)
JSON does not allow comments
JSON data type
null:
null
string:
"ssq"
boolean:
ture
number:
12
object:
{ "name": "ssq", "age": 12, "gender": ture, "boyfrind": null }
array:
["张三", "李四", "王五"]
JSON basic format
var obj = [ {"name": "ss", "age": 12, "email": "ssss", "url": "sssss.com", "images": ["./images/01.jpg"]}, {"name": "ss", "age": 12, "email": "ssss", "url": "sssss.com", "images": ["./images/01.jpg"]}, {"name": "ss", "age": 12, "email": "ssss", "url": "sssss.com", "images": ["./images/01.jpg"]}, {"name": "ss", "age": 12, "email": "ssss", "url": "sssss.com", "images": ["./images/01.jpg"]}, {"name": "ss", "age": 12, "email": "ssss", "url": "sssss.com", "images": ["./images/01.jpg"]} ]
JSON conversion
Deserialize JSON in PHP
and convert it into the form of object array in PHP
01Example display
JSON 格式的字符串 // 把 JSON 格式的字符串转换为对象的过程叫做反序列化 // json_decode 默认反序列化时 将 JSON 中的对象转换为 PHP 中 stdClass 类型的对象 $data = json_decode($contents, true); // $data => [] ?>音乐列表
Rendering
The above is the detailed content of Introduction to the method of uploading json files in PHP (code example). For more information, please follow other related articles on the PHP Chinese website!