您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

返回JSON数据的接口解决方案

2024/8/29 11:37:05发布34次查看
返回json数据的接口
需要写一个只给出连接就可以返回json数据的接口 如何实现 请给出思路
------解决方案--------------------
http://sxxxxx/json.php?type=1
http://sxxxxx/json.php?type=2
header('content-type: application/json');
$type = isset($_get['type']) ? intval($_get['type']) : 1;
$array = array();
if ($type == 1) {
$array = array(test => i'm 1);
} else if ($type == 2) {
$array = array(test => i'm 2);
}
echo json_encode($array);

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product