PHP无法分配smarty变量

问题描述 投票:-1回答:1

我正在尝试使用PHP在smarty中分配一些变量,但smarty变量返回NULL。这是我的代码:

{php}
$GLOBALS['smarty']->assign("new_var", "somevalue");
{/php}

{$new_var|@var_dump}

上面的代码将返回NULL我不知道发生了什么。

php smarty
1个回答
2
投票

为什么不使用PHP文件?

require("application/libraries/Smarty/libs/Smarty.class.php"); // Smarty class Smarty                   
        $smarty = new Smarty();
        $smarty->assign('new_var' => $phpvar);
        $smarty->display('blabla.tpl');
© www.soinside.com 2019 - 2024. All rights reserved.