In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
What this article shares with you is the introduction and analysis of the performance of the PHP JSON interchange function. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
PHP language is rated as a powerful computer language by people in the industry, and many programmers use it as the basic language for website development and construction. In view of the petite nature and versatility of JSON, PHP adds a set of PHP JSON interchange functions for data by default after version 5.2:
Json_encode data to JSON
Conversion from json_decode JSON to PHP variables
These two PHP JSON interchange functions are particularly important when using Ajax frameworks such as jquery and Ext. Ext accepts data in JSON format by default, while jquery makes it easier and simpler to connect JSON. This article will use an example to discuss the application of PHP's JSON data function in jquery.
Jquery as a lightweight Ajax framework does seem short and concise, more suitable for Web programming foreground pages, more suitable for combination with PHP. One of the methods in jquery is: $. GetJSON, which is used to get data in JSON format from the server script page. In order, we first create a PHP script called json.php, which is as follows:
< ?php //创建一个联合数组,这里我们尽量真 实的模拟了一个从数据库中读取的记录 $a=array('name'=>'dog','sex'= >
'faught recently paranoid = > array ('li','wang','lian'))
$b=array ('name'= >' pig','sex'= >
'masking recently paranoid = > array ('liv','wange','liang'))
$arrayarray = array (0 = > $aline 1 = > $b)
/ / convert the array to a json data string
Echo json_encode ($array)
? >
Foreground page jquery code:
< script>$(document) .ready (function () {
$.getJSON (
'json.php'
Function (data) {
Var content= ""
For (var iTuno Bandi)
This example applies js's basic flow control for loop method when reading data in a loop, and also provides a traversal method in jquery. Each interested brothers can learn about this method by themselves, and the underlying implementation is also based on for loop.
Note: json_encode json_decode 's two PHP JSON interchange functions are available only after PHP5.2, and using them earlier than the previous version will report an error that the function cannot be found!
The above is the introduction and analysis of the performance of the PHP JSON interchange function, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.