yii 返回json数据

YII 报错:

Response content must not be an array

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

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

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

return [
    'id' => $id,
    'remark' => $remark,
];
原文地址:https://www.cnblogs.com/GetcharZp/p/12425723.html