/**
* @link http://jianboo.com
*
* @param bool $id
*
* @return mixed
* @return bool | string | JSON
*
* @example
* <javascript>
* $.post('index.php?action=add',{key: 1001, value: 'JSON Object'})
* </javascript>
*
* @todo finish function
*
* function foo
* @since Version 2.0.1
*
* @version beta1.0.1
*
* @deprecated deprecated since 2.0
*
* @author Jianbo Li <jianbooo.com>
*
* @copyright Copyright (c) 2017, Jianbo Li
*
* @internal
**/
示例1
/**
* JSON Request
* 服务端接收的POST数据为JSON格式
*
* @param raw
* @return Array
**/
public function request () {
return json_decode(file_get_contents("php://input"), true);
}
示例2
/**
* Custom Ajax Response
* 以JSON格式输出结果,用于返回Ajax请求
*
* @param Array $data
* @return JSON
*
* @example
* $this->response(array("code"=> 200, "data"=> [1,2,3,4,5,6]))
*
**/
public function response($data) {
header("Content-type:application/json");
print_r(json_encode($data));
}
网友评论