smarty模板if使用

if标签

数据

$page  = [
\'count\'=>string\'19\'
\'page\'=>2
\'pages\' =>2
\'prepage\' => 1
\'nextpage\' =>  2
\'can_pre\' =>  1
\'can_next\' =>  0
]

格式

{if $num eq 22}
这部分执行了22
{elseif $num eq 33}
这部分执行了33
{else}
没有输出任何东西
{/if}

使用

//如果 can_pre 为0,打印disabled 
{if $page.can_pre eq 0}disabled {/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 
if $_global_password} 是判断变量存不存在....
{if $_global_password!==\\\'\\\'} 是判断变量等不等于空....
equal : 相等、not equal:不等于、greater than:大于、less than:小于、less than or equal:小于等于、great than or equal:大于等于、is even:是偶数、is odd:是奇数、is not even:不是偶数、is not odd:不是奇数、not:非、mod:取余、div by:被。。。除

暂无评论

相关推荐

微信扫一扫,分享到朋友圈

smarty模板if使用