【发布时间】:2018-12-24 18:33:38
【问题描述】:
这是我的控制器
$pid = json_decode(file_get_contents('php://input'), true);
foreach ($pid as $key => $value) {
foreach ($value as $keys => $values) {
$c_res = $this->Model_master->get_sup($values);
echo json_encode($c_res, 200);
}
}
这是我的模特
$q = $this->db->select('contact_number')->from('shopxie_people')
->where("p_id = ".$value)
->get();
return $q->result_array();
这以 html 形式显示我的结果,但是当我将其更改为 json 时,它给了我
语法错误
在邮递员内容类型中也显示为 text/html;
为什么在我的代码中用 json 编码后还是会发生这种情况?
【问题讨论】:
-
“改成json”是什么意思?你能分享确切的错误信息吗?
-
什么是
200injson_encode($c_res, 200)删除它 -
@pradeep 仍然给出同样的错误
-
不要让它进入 foreach 循环
-
@NicoHaase 我正在使用邮递员,所以我可以选择将输出更改为 html、json、xml、文本、自动
标签: php json codeigniter codeigniter-3