smarty 模板if else使用实例与入门教程
smarty 主要功能是完成美工与程序分离,并且使用的缓存技术,减轻服务器的负载,
smarty 以在文件中放置特殊的“smarty标签”来产生网页内容。这些标签会被处理并替换成其他的内容。
*/
require('smarty/libs/smarty.class.php教程');
$tpl = new smarty();
$tpl->template_dir = 'd/'
$tpl->compile_dir = 'd/template_c';
$tpl->compile_check = false;//$cfg['debug'];
$tpl->debugging = false;
$tpl->caching = false;
$tpl->cache_lifetime = 3600;
$tpl->left_delimiter = '';
$array = 'www.111cn.net'
$tpl->assign('datalist', $array);
$tpl->display('a.tpl');
/*
a.tpl
echo 'aaa';
还有另一种方法
{if $name eq 'fred'}
welcome sir.
{elseif $name eq 'wilma'}
welcome ma'am.
{else}
welcome, whatever you are.
{/if}
{* an example with or logic *}
{if $name eq 'fred' or $name eq 'wilma'}
...
{/if}
本文章原创于www.111cn.net转载注明出处
