thinkphp返回Json数据格式
//编写类方法用$this->ajaxReturn()返回数据
public function index(){
$setting = M('setting');
$map['lang'] = array('in','1,0');
$data = $setting->where($map)->field('name,data')->select();
$this->ajaxReturn($data,'JSON');
}(PS:PHP Q扣峮:276167802,验证:csl)
返回数据页面显示如下
[{"name":"site_name","data":"\u4e0a\u6d77\u610f\u9017\u4fe1\u606f\u6280\u672f\u6709\u9650\u516c\u53f8"},{"name":"site_title","data":"\u624b\u673aAPP,\u624b\u673a\u7f51\u7ad9\u5efa\u8bbe,\u4e0a\u6d77\u610f\u9017\u4fe1\u606f\u6280\u672f\u6709\u9650\u516c\u53f8"}]
以上是本文关于thinkphp返回Json的数据格式,希望本文对广大php开发者有所帮助,感谢阅读本文。
本文转自:http://www.2cto.com/kf/201312/269160.html
转载于:https://blog.51cto.com/chengxuyuan/1655624