首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >空响应Web服务原则2瘦3

空响应Web服务原则2瘦3
EN

Stack Overflow用户
提问于 2017-04-14 02:11:08
回答 1查看 74关注 0票数 0

发生了一些非常奇怪的事情,下面的代码来自我在Web服务中使用Slim 3和Doctrine 2的一个请求,我得到了一个空响应,我知道它被填充了,但它返回了空!

代码语言:javascript
复制
    $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

我知道这个问题很不专业,但我正在引用我朋友的知识来帮助我解决这个问题。)

EN

回答 1

Stack Overflow用户

发布于 2017-05-04 14:58:52

json_encode($data_response)正在返回false。使用json_last_error()找出问题所在。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43399067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档