改进Response类create方法

This commit is contained in:
thinkphp
2018-03-27 13:34:38 +08:00
parent 97de5ec026
commit 46ea48642a

View File

@@ -69,9 +69,7 @@ class Response
*/ */
public static function create($data = '', $type = '', $code = 200, array $header = [], $options = []) public static function create($data = '', $type = '', $code = 200, array $header = [], $options = [])
{ {
$type = empty($type) ? 'null' : strtolower($type); $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst(strtolower($type));
$class = false !== strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst($type);
if (class_exists($class)) { if (class_exists($class)) {
$response = new $class($data, $code, $header, $options); $response = new $class($data, $code, $header, $options);
} else { } else {