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

WBOY
Release: 2016-06-13 11:56:16
Original
1005 people have browsed it

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 />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template