; 'NAME' => 'Roger Rabbit',
'AGE' => '16',
);
$template = new SmartTemplate('users.html');
$template->assign( 'admin', $admin );
$template->assign( 'guest', $guest );
$template->output();
?>[/code:1:b920254608]
模板(user.html): 占位符(PLACEHOLDER)对应数组,“.”对应数组“[]”
[code:1:b920254608]Admin Name: {admin.NAME}
Admin Age: {admin.AGE}
Guest Name: {guest.NAME}
Guest Age: {guest.AGE}[/code:1:b920254608]
输出:
[code:1:b920254608]Admin Name: John Doe
Admin Age: 42
Guest Name: Roger Rabbit
Guest Age: 16[/code:1:b920254608]
[b:b920254608]例子5: 使用数组命名空间[/b:b920254608]
[code:1:b920254608]<?php
$users = array(
'admin' => array(
 
'AGE' => '16',
);
$template = new SmartTemplate('users.html');
$template->assign( 'admin', $admin );
$template->assign( 'guest', $guest );
$template->output();
?>[/code:1:b920254608]
模板(user.html): 占位符(PLACEHOLDER)对应数组,“.”对应数组“[]”
[code:1:b920254608]Admin Name: {admin.NAME}
Admin Age: {admin.AGE}
Guest Name: {guest.NAME}
Guest Age: {guest.AGE}[/code:1:b920254608]
输出:
[code:1:b920254608]Admin Name: John Doe
Admin Age: 42
Guest Name: Roger Rabbit
Guest Age: 16[/code:1:b920254608]
[b:b920254608]例子5: 使用数组命名空间[/b:b920254608]
[code:1:b920254608]<?php
$users = array(
'admin' => array(
 
| 对此文章发表了评论 |
