function renderItem($item) {
if (isset($item)) {
<li>
<a href="!#{$item['url']}">#{$item['title']}</a>
</li>
}
}
<ul>
renderItem(array('url' => 'http://google.com/', 'title' => 'Google'));
renderItem(array('url' => 'http://www.baidu.com/', 'title' => '百度'));
</ul>
<?php function renderItem($item) {
if (isset($item)) { ?>
<li>
<a href="<?php echo $item['url'] ?>"><?php echo htmlentities($item['title']) ?></a>
</li>
<?php }
} ?>
<ul>
<?php renderItem(array('url' => 'http://google.com/', 'title' => 'Google'));
renderItem(array('url' => 'http://www.baidu.com/', 'title' => '百度')); ?>
</ul>
<ul>
<li>
<a href="http://google.com/">Google</a>
</li>
<li>
<a href="http://www.baidu.com/">百度</a>
</li>
</ul>
MIT © zswang