Blogger Information
Blog 3
fans 0
comment 0
visits 5384
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php如何用get方式写一个简单的API接口并返回Json
waoyou
Original
1844 people have browsed it

最近某些场景需要用到php,部分会用到API方便自定义指定格式的返回值,这里当个记录当个笔记。

代码截图:

运行效果:

php如何用get方式写一个简单的API接口并返回Json源代码

  1. <?php
  2. header('Content-type:text/json');//定义请求头
  3. $data =array('request'=>'success','msg'=>'35235');
  4. $data_json = json_encode($data); //用json格式编码
  5. echo $data_json;//返回请求json数据
  6. ?>

原文地址:https://www.waoyou.com/295.html

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post