內容列表php
$template_dir [模板目錄變量]html
[從PHP分配的變量]api
[從配置文件讀取的變量]數組
[{$smarty} 保留變量]yii
Smarty有幾種不一樣類型的變量.函數
變量 的類型取決於它的前綴是什麼符號(或者被什麼符號包圍)spa
Smarty的變量能夠直接被輸出或者做爲函數屬性和修飾符(modifiers)的參數,或者用於內部的條件表達式等等.orm
若是要輸出一個變量,只要用定界符將它括起來就能夠.例如:htm
{$Name} {$Contacts[row].Phone} <body bgcolor="{#bgcolor#}"> |
內容列表對象
關聯數組
數組下標
對象
調用從PHP分配的變量需在前加"$"符號.(譯註:同php同樣)
調用模板內的assign函數分配的變量也是這樣.(譯註:也是用$加變量名來調用)
例 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.