Home > php教程 > php手册 > thinkphp返回Json的数据格式

thinkphp返回Json的数据格式

WBOY
Release: 2016-06-13 09:46:16
Original
1666 people have browsed it

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)
Copy after login


返回数据页面显示如下

[{"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开发者有所帮助,感谢阅读本文。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template