首页 >后端开发 >php教程 >smarty中assign()这个函数是怎么定义的

smarty中assign()这个函数是怎么定义的

WBOY
WBOY原创
2016-06-13 11:56:161018浏览

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 />

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn