tp5.2 rest类 response方法直接返回空字符串?

浏览:4421 发布日期:2016/11/08 分类:ThinkPHP5专区 关键字: rest
$this->response('hello','json',200);
返回空字符串
打印后可见对象参数
<pre>object(think\response\Json)#15 (7) {
["options":protected] => array(1) {
["json_encode_param"] => int(256)
}
["contentType":protected] => string(16) "application/json"
["data":protected] => string(5) "hello"
["charset":protected] => string(5) "utf-8"
["code":protected] => int(200)
["header":protected] => array(1) {
["Content-Type"] => string(31) "application/json; charset=utf-8"
}
["content":protected] => NULL
}
</pre>"
所以应该怎么处理?
protected function response($data, $type = 'json', $code = 200)
{
return Response::create($data, $type)->code($code);

}
最佳答案
评论( 相关
后面还有条评论,点击查看>>