From af648cfa8d5ac45587ad6ada306f3547ba7cd19a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 14 Jun 2016 11:49:07 +0800 Subject: [PATCH] =?UTF-8?q?ViewResponse=E7=B1=BB=E5=A2=9E=E5=8A=A0getVars?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/response/View.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/library/think/response/View.php b/library/think/response/View.php index e92cd052..224e3b60 100644 --- a/library/think/response/View.php +++ b/library/think/response/View.php @@ -38,7 +38,7 @@ class View extends Response /** * 视图变量赋值 - * @access protected + * @access public * @param array $vars 模板变量 * @return $this */ @@ -48,6 +48,21 @@ class View extends Response return $this; } + /** + * 获取视图变量 + * @access public + * @param string $name 模板变量 + * @return mixed + */ + public function getVars($name = null) + { + if(is_null($name)){ + return $this->vars; + }else{ + return isset($this->vars[$name]) ? $this->vars[$name] : null; + } + } + /** * 模板变量赋值 * @access public