zl程序教程

您现在的位置是:首页 >  大数据

当前栏目

yii 返回json数据

数据JSONJSON 返回 yii
2023-09-11 14:21:10 时间

YII 报错:

Response content must not be an array

 

yii 在 Controller 中返回数据,要加返回数据前加下面代码:

Yii::$app->response->format = Response::FORMAT_JSON;

返回的数据为 return array(),举个栗子:

return [
    'id' => $id,
    'remark' => $remark,
];