AppController.php
722 Bytes
<?php
namespace app\wx\controllers;
use Yii;
use yii\web\Controller;
/**
* 该基类的主要作用是,提供一个便利的方法集成。
*/
class AppController extends Controller
{
/** @var \yii\web\request **/
public $request;
/** @var \yii\web\response **/
public $response;
/**
* @throws yii\web\HttpException
*/
public function init()
{
parent::init();
$this->request = Yii::$app->getRequest();
$this->response = Yii::$app->getResponse();
}
/**
* 渲染 JSON 数据结果
* @param $data
* @return string
*/
public function renderJson($data)
{
return json_encode($data, JSON_UNESCAPED_UNICODE);
}
}