欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php json相關(guān)函數(shù)用法示例

 更新時間:2017年03月28日 11:52:57   作者:PHP__廊外詩鴿  
這篇文章主要介紹了php json相關(guān)函數(shù)用法,列舉了json_encode、json_decode及json_last_error的功能,并實例分析了json_encode與json_decode函數(shù)的具體使用技巧,需要的朋友可以參考下

本文實例講述了php json相關(guān)函數(shù)用法。分享給大家供大家參考,具體如下:

函數(shù)列表:

函數(shù) 描述
json_encode 對變量進(jìn)行json編碼
json_decode 對json格式的字符串進(jìn)行解碼,轉(zhuǎn)換為php變量
json_last_error 返回最后發(fā)生的錯誤

For example 1: json_encode

$arr=array("A"=>"a","B"=>"b","C"=>"c","D"=>"d");
echo json_encode($arr);

output:

{"A":"a","B":"b","C":"c","D":"d"}

For example 2: json_decode

$arr='{"A":"a","B":"b","C":"c","D":"d"}';
var_dump(json_decode($arr));
var_dump(json_decode($arr,true));

output:

object(stdClass)[1]
 public 'A' => string 'a' (length=1)
 public 'B' => string 'b' (length=1)
 public 'C' => string 'c' (length=1)
 public 'D' => string 'd' (length=1)
array (size=4)
 'A' => string 'a' (length=1)
 'B' => string 'b' (length=1)
 'C' => string 'c' (length=1)
 'D' => string 'd' (length=1)

PS:這里再為大家推薦幾款比較實用的json在線工具供大家參考使用:

在線JSON代碼檢驗、檢驗、美化、格式化工具:
http://tools.jb51.net/code/json

JSON在線格式化工具:
http://tools.jb51.net/code/jsonformat

在線XML/JSON互相轉(zhuǎn)換工具:
http://tools.jb51.net/code/xmljson

json代碼在線格式化/美化/壓縮/編輯/轉(zhuǎn)換工具:
http://tools.jb51.net/code/jsoncodeformat

C語言風(fēng)格/HTML/CSS/json代碼格式化美化工具:
http://tools.jb51.net/code/ccode_html_css_json

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP中json格式數(shù)據(jù)操作技巧匯總》、《PHP數(shù)學(xué)運(yùn)算技巧總結(jié)》、《PHP基本語法入門教程》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家PHP程序設(shè)計有所幫助。

相關(guān)文章

最新評論