From 4b90edad711c4c1f4f2258a86ac1d1f980136b83 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 20 Dec 2015 10:34:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BView=E7=B1=BB=E5=AF=B9engine?= =?UTF-8?q?=E7=9A=84=E5=88=A4=E6=96=AD=20=E5=A6=82=E6=9E=9C=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BAphp=20=E5=88=99=E4=BD=BF=E7=94=A8=E5=8E=9F?= =?UTF-8?q?=E7=94=9FPHP=E8=A7=A3=E6=9E=90=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/view.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/library/think/view.php b/library/think/view.php index d114be67..c8d41e06 100644 --- a/library/think/view.php +++ b/library/think/view.php @@ -87,8 +87,12 @@ class View */ public function engine($engine, array $config = []) { - $class = '\\think\\view\\driver\\' . ucwords($engine); - $this->engine = new $class($config); + if('php'==$engine){ + $this->engine = 'php'; + }else{ + $class = '\\think\\view\\driver\\' . ucwords($engine); + $this->engine = new $class($config); + } return $this; } @@ -141,13 +145,13 @@ class View // 页面缓存 ob_start(); ob_implicit_flush(0); - if ($this->engine) { - // 指定模板引擎 - $this->engine->fetch($template, $vars, $cache); - } else { + if ('php' == $this->engine || empty($this->engine)) { // 原生PHP解析 extract($vars, EXTR_OVERWRITE); is_file($template) ? include $template : eval('?>' . $template); + } else { + // 指定模板引擎 + $this->engine->fetch($template, $vars, $cache); } // 获取并清空缓存 $content = ob_get_clean();