Json_encode () JSON encoding a variable
Json_decode () decodes a JSON-formatted string into a PHP variable
Json_last_error returns the last occurrence of the error
Resource types cannot be converted to JSON format or converted to serialize data format, similar to the identity of a file.
the similarities and differences of JSON data format and serialize data format
Same point
1. Convert other data types into a string that can be transmitted
2, are the structural data
Different points
1, serialize serialized data format to save the original type of data
2, JSON data format to be more concise than the data format after serialize serialization
Usage scenarios:
1, JSON is suitable for large amount of data, do not require the retention of the original data type use
2, serialize suitable for storing data strings with encryption, to prevent the interception of data in the middle of the deserialization of the break
- Header ("content-type:text/html; Charset=utf-8 "); Statement code
- function Createhtmltag ($tag = "") {
- echo "$tag
";
- }
- Createhtmltag ("Www.aseoe.Com");
- Createhtmltag ("JSON and serialize contrast");
- $member = Array ("Site", "Tree"); Define an array
- Var_dump ($member); Print
- $JSONOBJ = Json_encode ($member); Parse into JSON data format
- $SERIALIZEOBJ = serialize ($member); Parsing into Serialize data format
- Createhtmltag ($JSONOBJ); No need to save data format
- Createhtmltag ($SERIALIZEOBJ); Can encrypt the transmitted data to prevent interception
- ?>