如何检查特定值是否已分配给Smarty,如果没有分配(默认)值?
回答:
if ($this->cismarty->get_template_vars('test') === null) { $this->cismarty->assign('test','Default value'); }
Smarty 2
if ($smarty->get_template_vars('foo') === null) { $smarty->assign('foo','some value'); }
Smarty 3
if ($smarty->getTemplateVars('foo') === null) { $smarty->assign('foo','some value'); }
请注意,对于Smarty 3,您必须使用$smarty-> getTemplateVars.