Embedding Vars in Double Quotes

PHP Smarty

Smarty - the compiling PHP template engine
Prev 来源:PHP中文社区 Chapter 3. Basic Syntax[第3章.基本语法] Next

Embedding Vars in Double Quotes

[双引号里值的嵌入]

SYNTAX EXAMPLES:
{func var="test $foo test"} <-- sees $foo
{func var="test $foo_bar test"} <-- sees $foo_bar
{func var="test $foo[0] test"} <-- sees $foo[0]
{func var="test $foo[bar] test"} <-- sees $foo[bar]
{func var="test $foo.bar test"} <-- sees $foo (not $foo.bar)
{func var="test `$foo.bar` test"} <-- sees $foo.bar

PRACTICAL EXAMPLES:
{include file="subdir/$tpl_name.tpl"} <-- will replace $tpl_name with value
{cycle values="one,two,`$smarty.config.myval`"} <-- must have backticks

Prev 来源:PHP中文社区 Home Next
Up