我正在尝试使用PHP在smarty中分配一些变量,但smarty变量返回NULL。这是我的代码:
{php}
$GLOBALS['smarty']->assign("new_var", "somevalue");
{/php}
{$new_var|@var_dump}
上面的代码将返回NULL
我不知道发生了什么。
为什么不使用PHP文件?
require("application/libraries/Smarty/libs/Smarty.class.php"); // Smarty class Smarty
$smarty = new Smarty();
$smarty->assign('new_var' => $phpvar);
$smarty->display('blabla.tpl');