Json响应返回
HTTP/1.0 200 OK Cache-Control: no-cache Content-Type: application/json
Date: Mon, 20 Jul 2015 09:24:20 GMT {"success":true}`
或
HTTP/1.0 200 OK Cache-Control: no-cache Content-Type: application/json
Date: Mon, 20 Jul 2015 09:24:20 GMT {"error":"Trying to get property of non-object"}
如何编写php代码来检查是否存在成功或错误。
像这样做
$abc=$this->store($values,$reallocation_type,'multiple');
if(strpos($abc,'success') !== false)
{
echo "YES";
}
答案 0 :(得分:1)
这可能就是你要找的东西。
$response = @json_decode($abc);
if ($response && true === $response->success) {
// success
} else {
//failure
}