开发者

php and smarty var. value

smarty file
{php}
some php code...

    $php_var = "{/php}{$smarty_var}{php}";
    echo $php_var;

some php code ...
{/php}
smarty file

Why '$php_var' value is: ?>

How get $smarty_var value?

开发者_运维知识库Thanks


The reason that $php_var is wrong is because you accidentally closed your {php} when you put a {/php} in the PHP code there. Smarty doesn't understand enough to care that it's in a quoted string.

To actually get the smarty variable, use $this->get_template_vars('smarty_var') somewhere in your '{php}' block.

Alternately, split the template into two smaller ones invoked in sequence.


Instead of opening and closing {php} tags. You could try,

{php}
$php_var = $this->get_template_vars('your_smarty_var_name');
echo $php_var;
{/php}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜