简体   繁体   English

PHP无法分配smarty变量

[英]PHP can't assign smarty variable

I'm trying to assign some variable in smarty using PHP but the smarty variable return NULL. 我正在尝试使用PHP在smarty中分配一些变量,但是smarty变量返回NULL。 Here is my code : 这是我的代码:

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

{$new_var|@var_dump}

The code above will return NULL I don't know what is happening. 上面的代码将返回NULL我不知道发生了什么。

Why don't use a PHP file ? 为什么不使用PHP文件?

require("application/libraries/Smarty/libs/Smarty.class.php"); // Smarty class Smarty                   
        $smarty = new Smarty();
        $smarty->assign('new_var' => $phpvar);
        $smarty->display('blabla.tpl');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM