yii ajax 返回json在控制器中的写法

来源:互联网 发布:网络安全监管机构 编辑:程序博客网 时间:2024/05/30 04:44

a. 官网的写法

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

return ['message' => 'hello world'];

b.  公司大佬的选择

   return  json_encode(['message' => 'hello world']);

原创粉丝点击