Home >Backend Development >PHP Tutorial >ajax3—php(29)
1. Application of json in Ajax
For the processing of large batches of data:
1) } To simulate an unordered collection of attributes
1. About json in phpCurrently, most ajax programs use json objects as data transfer methods, so many languages have built-in support for json Object support. In php, there are two functions for encoding and decoding jsonl string json_encode (mixed $value)Generate a string in json format
l mixed json_decode (string $json [, bool])
Parse json
The second parameter indicates whether to parse into an array or an object. The default is false, which means parsing into an object
1) json_encode
If you want to get data in json format, you must first get an array or Object
2) json_decode
3) json_decode
Json currently only supports utf-8 format 3, Ajax uses jsonExample 1: Return two using json Four arithmetic operations of numbers Server code:
Example 2: Return multiple pieces of data from the server
Ajax program: Php program:The above has introduced ajax3-php (29), including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.