需要写一个只给出连接就可以返回JSON数据的接口 如何实现 请给出思路
Easily find JSON paths within JSON objects using our intuitive Json Path Finder
30
给出连接 输出 json?是这个意思?
$arr = array('连接成功');echo json_encode($arr); 给出连接 输出 json?是这个意思?
差不多吧
就是给一个连接 可以通过连接拼的参数不同来返回不同的数据
不是用switch 就是用if.
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); 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);
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号