我正在使用Codeigniter的资源控制器从我的API输出一些数据。
例如:
$data = ['id' => 8, 'name': 'John Doe', 'age': 27];
return $this->respond($data, 200);有没有办法减少输出?
发布于 2021-11-16 14:56:10
您可能需要执行以下操作:
$data = ['id' => 8, 'name': 'John Doe', 'age': 27];
//add the header here
header('Content-Type: application/json');
echo json_encode( $data );尝试使用标题类型以获得正确的结果
我希望有一个codeigniter设置或一些配置值。
没有这样的东西,内置的。
https://stackoverflow.com/questions/69990212
复制相似问题