顺德公农庄 发表于 2017-4-8 12:31:36

Smarty 模板 -- 从php分配的变量

index.php:
$smarty = new Smarty;
$smarty->assign('Contacts',
array('555-222-9876',
'zaphod@slartibartfast.com',
array('555-444-3333',
'555-111-1234')));
$smarty->display('index.tpl');
index.tpl:
{$Contacts}<br>
{$Contacts}<br>
{* you can print arrays of arrays as well *}
{$Contacts}<br>
{$Contacts}<br>
OUTPUT:
555-222-9876<br>
zaphod@slartibartfast.com<br>
555-444-3333<br>
555-111-1234<br>
页: [1]
查看完整版本: Smarty 模板 -- 从php分配的变量