Rumah >pembangunan bahagian belakang >tutorial php >smarty中assign()这个函数是怎么定义的
smarty中assign()这个函数是如何定义的
谁能帖出这个函数的代码啊,以及它的原理
------解决方案--------------------
smarty_internal_data.php
/**<br /> * assigns a Smarty variable<br /> *<br /> * @param array<br><font color='#FF8000'>------解决方案--------------------</font><br>string $tpl_var the template variable name(s)<br /> * @param mixed $value the value to assign<br /> * @param boolean $nocache if true any output of this variable will be not cached<br /> * @param boolean $scope the scope the variable will have (local,parent or root)<br /> */<br /> public function assign($tpl_var, $value = null, $nocache = false)<br /> {<br /> if (is_array($tpl_var)) {<br /> foreach ($tpl_var as $_key => $_val) {<br /> if ($_key != '') {<br /> if (isset($this->tpl_vars[$_key])) {<br /> $this->tpl_vars[$_key]->value = $_val;<br /> $this->tpl_vars[$_key]->nocache = $nocache;<br /> } else {<br /> $this->tpl_vars[$_key] = new Smarty_variable($_val, $nocache);<br /> }<br /> }<br /> }<br /> } else {<br /> if ($tpl_var != '') {<br /> if (isset($this->tpl_vars[$tpl_var])) {<br /> $this->tpl_vars[$tpl_var]->value = $value;<br /> $this->tpl_vars[$tpl_var]->nocache = $nocache;<br /> } else {<br /> $this->tpl_vars[$tpl_var] = new Smarty_variable($value, $nocache);<br /> }<br /> }<br /> }<br /> }<br />