【发布时间】:2015-02-15 13:59:23
【问题描述】:
有人知道为什么吗 $this-response($somearray, 200); 无法输出长 JSON? (或长数组) 例如,如果我将查询限制为最后 10 行,但如果我将其限制为 100,我可以输出数据库结果 JSON 被修剪,在我的客户端应用程序中,我得到“输入意外结束”。如果我简单地更改上述语句 回声 json_encode($somearray); 它完美无瑕。
对不起。我需要澄清我的问题。我在用 https://github.com/chriskacerguis/codeigniter-restserver
function transits_get()
{
$sessionId = $this->input->get_request_header('Sessionid', TRUE);
$transits = $this->Transit_model->get_transits( $sessionId );
if($transits)
{
//$this->output->set_content_type('application/json');
//$this->output->set_output(json_encode($transits)); //works
//echo json_encode($transits); //works
$this->response($transits, 200); // 200 being the HTTP response code //Does not work
}
else
{
$this->response(array('error' => 'There is no transit records in the database!'), 404);
}
}
【问题讨论】:
-
你的 php 代码在哪里?
标签: php codeigniter rest server