发生了一些非常奇怪的事情,下面的代码来自我在Web服务中使用Slim 3和Doctrine 2的一个请求,我得到了一个空响应,我知道它被填充了,但它返回了空!
$data = $request->getParsedBody();
$intervention_items = $this->em->getRepository('App\Entity\V_Interventionitems')
->findAll(array('ic_interventiontype_id' => $data['it_id']));
foreach ($intervention_items as $int_items){
$data_response[] = $int_items->toArray();
//echo json_encode($int_items->toArray()); here prints the info right
}
return $response->withStatus(200)
->withHeader('Content-Type', 'application/json')
->write(json_encode($data_response)); //here returns empty我知道这个问题很不专业,但我正在引用我朋友的知识来帮助我解决这个问题。)
发布于 2017-05-04 14:58:52
json_encode($data_response)正在返回false。使用json_last_error()找出问题所在。
https://stackoverflow.com/questions/43399067
复制相似问题