think\Response\Josn 自动转 create_time

浏览:80 发布日期:2021/04/22 分类:ThinkPHP5专区
有没有大牛知道咋回事



<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <[email protected]>
// +----------------------------------------------------------------------

namespace think\response;

use think\Response;

class Json extends Response
{
// 输出参数
protected $options = [
'json_encode_param' => JSON_UNESCAPED_UNICODE,
];

protected $contentType = 'application/json';

/**
* 处理数据
* @access protected
* @param mixed $data 要处理的数据
* @return mixed
* @throws \Exception
*/
protected function output($data)
{
try {
dump($data);
// 返回JSON数据格式到客户端 包含状态信息
$data = json_encode($data, $this->options['json_encode_param']);
dump($data);
die;
if (false === $data) {
throw new \InvalidArgumentException(json_last_error_msg());
}

return $data;
} catch (\Exception $e) {
if ($e->getPrevious()) {
throw $e->getPrevious();
}
throw $e;
}
}

}

两次打印
["create_time"] => int(1618899245)
"create_time":"2021-04-20 14:14:05"
最佳答案
评论( 相关
后面还有条评论,点击查看>>