简化slog类

This commit is contained in:
thinkphp
2015-12-08 12:49:26 +08:00
parent a679f878df
commit 64348512ef
5 changed files with 59 additions and 134 deletions

View File

@@ -11,10 +11,6 @@
namespace think;
use think\Config as Config;
use think\Transform as Transform;
use think\Url as Url;
class Response
{
@@ -23,9 +19,10 @@ class Response
* @access protected
* @param mixed $data 要返回的数据
* @param String $type 返回数据格式
* @param bool $exit 是否终止执行
* @return void
*/
public static function returnData($data, $type = '')
public static function returnData($data, $type = '', $exit = true)
{
$headers = [
'json' => 'application/json',
@@ -55,7 +52,11 @@ class Response
$data = $handler . '(' . Transform::jsonEncode($data) . ');';
break;
}
echo $data;
if ($exit) {
exit($data);
} else {
echo $data;
}
}
/**
@@ -70,10 +71,10 @@ class Response
public static function result($data, $code = 0, $msg = '', $type = '')
{
$result = [
'code' => $code,
'msg' => $msg,
'time' => NOW_TIME,
'data' => $data
'code' => $code,
'msg' => $msg,
'time' => NOW_TIME,
'data' => $data,
];
self::returnData($result, $type);
}