可以给assign单独传一个array作为参数
一段smarty源代码,可以给assign单独传一个array作为参数
/**
* assigns values to template variables
*
* @param array|string $tpl_var the template variable name(s)
* @param mixed $value the value to assign
*/
function assign($tpl_var, $value = null)
{
if (is_array($tpl_var)){
foreach ($tpl_var as $key => $val) {
if ($key != ”) {
$this->_tpl_vars[$key] = $val;
}
}
} else {
if ($tpl_var != ”)
$this->_tpl_vars[$tpl_var] = $value;
}
}

Recent Comments