模板文件中可以使用if else等判断语句,即可以将一些逻辑程序放在模板里。
"eq","ne","neq","gt","lt","lte","le","gte" "ge","is even","is odd","is not even","is notodd","not","mod","div by","evenby","odd by","==","!=",">","<","<=",">="这些是if中可以用到的比较。看看就能知道什么意思吧。
下面详细说明一下这些操作符的意思吧.
eq相等, ne、neq不相等, gt大于, lt小于 gte、ge大于等于 lte、le 小于等于 not非, mod求模 is [not] div by是否能被某数整除, is [not] even是否为偶数 $a is [not] even by $b即($a / $b) % 2 == 0 is [not] odd是否为奇 $a is not odd by $b即($a / $b) % 2 != 0
当然也可以直接用PHP的==、!=、>、<、<=、>= 等
示例代码1:
{if $name eq"Fred"} WelcomeSir.
{elseif $name eq"Wilma"}
WelcomeMa'am.
Welcome,whatever you are.
{/if}
{if $sm_fenye neq ""} <a href="view.PHP?id={$sm_fenye[0]}">上一页:{$sm_fenye[2]}</a> {/if}
{if $sm_fenye1 neq ""} <a href="view.PHP?id={$sm_fenye1[0]}"> 下一页: {$sm_fenye1[2]} </a> {/if}