From 168616bab88febc56702c584546d5e9a9852ab27 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 5 Mar 2016 11:50:20 +0800 Subject: [PATCH] =?UTF-8?q?View=E7=B1=BB=E7=9A=84fetch=E6=96=B9=E6=B3=95?= =?UTF-8?q?=20=E5=9C=A8=E5=85=B3=E9=97=ADresponse=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=20?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E8=BE=93=E5=87=BA=20controller=E7=B1=BB?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0display=E6=96=B9=E6=B3=95=E4=BD=9C=E4=B8=BAfe?= =?UTF-8?q?tch=E7=9A=84=E5=88=AB=E5=90=8D=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Controller.php | 13 +++++++++++++ library/think/View.php | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/library/think/Controller.php b/library/think/Controller.php index 06649a03..5e34f699 100644 --- a/library/think/Controller.php +++ b/library/think/Controller.php @@ -92,6 +92,19 @@ class Controller return $this->view->fetch($template, $vars, $config); } + /** + * 加载模板和页面输出 可以返回输出内容 + * @access public + * @param string $template 模板文件名 + * @param array $vars 模板输出变量 + * @param array $config 模板参数 + * @return mixed + */ + public function display($template = '', $vars = [], $config = []) + { + return $this->view->fetch($template, $vars, $config); + } + /** * 渲染内容输出 * @access public diff --git a/library/think/View.php b/library/think/View.php index 7489b6a9..f1135ae5 100644 --- a/library/think/View.php +++ b/library/think/View.php @@ -186,6 +186,10 @@ class View $replace = $this->config['parse_str']; $content = str_replace(array_keys($replace), array_values($replace), $content); } + if (!Config::get('response_auto_output')) { + // 自动响应输出 + return Response::send($content, Response::type()); + } return $content; }