从PHP分配的变量

Smarty - the compiling PHP template engine
Prev 来源:PHP中文社区 Next

Table of Contents[内容列表]
Associative arrays[关联数组]
Array indexes[数组下标]
Objects[对象]

Variables that are assigned from PHP are referenced by preceding them with a dollar sign $.
Variables assigned from within the template with the assign function are also displayed this way.

调用从PHP分配的变量需在前加"$"符号.(译注:同php一样)
调用模板内的assign函数分配的变量也是这样.(译注:也是用$加变量名来调用)

Example 4-1. assigned variables
例 4-1.分配的变量

index.php:

$smarty = new Smarty;
$smarty->assign("firstname", "Doug"); $smarty->assign("lastLoginDate", "January 11th, 2001"); $smarty->display("index.tpl");
index.tpl: Hello {$firstname}, glad to see you could make it. <p> Your last login was on {$lastLoginDate}. OUTPUT: Hello Doug, glad to see you could make it. <p> Your last login was on January 11th, 2001.
文章导航