eq相等,smarty 比较操作符!

jackxiang 2009-2-4 12:04 | |
is [not] odd是否为奇,
$a is not odd by $b即($a / $b) % 2 != 0 示例:
{if $smarty.section.outer.index is odd by 2}
odd英文是奇数的意思,也就是说这个能被2整除:

以上摘自smarty自己的demon。而odd则参考如下:
http://zjsky1989.blog.163.com/blog/static/8158784820134632416404/

{if $smarty.section.outer.index is odd by 1}

0 -1 * John
1 -2 . Mary
2 -3 * James
3 -4 . Henry
4 -5 * Tom
5 -6 . Hello
0/1=0  非奇非偶,执行else项

1/1=1  奇数,执行if项

2/1=2  偶数,执行else项

3/1=3  奇数,执行if项

4/1=4 偶数,执行else项

5/1=5 奇数,执行if项
来自:http://www.ithao123.cn/content-4326244.html
—————————————————————————————————————————

eq相等,
f7Y"Y f3m @,V+Z }4X0 ne、neq不相等,
7C E z R S8P t,i:@ ^0 gt大于,
4d D H4F,Yg;D X)Y0 lt小于,PHPChina 开源社区门户 T f D |(s P9e
gte、ge大于等于,PHPChina 开源社区门户.L | \8i-C n:Q7]
lte、le 小于等于,PHPChina 开源社区门户 L8^ S \;u5_ ^$n/i"D
not非, mod求模。 PHPChina 开源社区门户 i ^ p a S&a
is [not] div by是否能被某数整除,
,B z M E m I w0 is [not] even是否为偶数,PHPChina 开源社区门户;J K H t"g o { I
$a is [not] even by $b即($a / $b) % 2 == 0,PHPChina 开源社区门户#K g P e!?/k$T e k e3F
is [not] odd是否为奇,PHPChina 开源社区门户 c b1^ F F e p7L
$a is not odd by $b即($a / $b) % 2 != 0 示例:

equal/ not equal/ greater than/ less than/ less than or equal/ great than or equal/后面的就不用说了

Smarty 中的 if 语句和 php 中的 if 语句一样灵活易用,并增加了几个特性以适宜模板引擎. if 必须于 /if 成对出现. 可以使用 else 和 elseif 子句. 可以使用以下条件修饰词:eq、ne、neq、gt、lt、lte、le、gte、ge、is even、is odd、is not even、is not odd、not、mod、div by、even by、odd by、==、!=、>、<、<=、>=. 使用这些修饰词时必须和变量或常量用空格格开.

Example 7-11. if statements
例 7-11. if 语句演示

{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}

{* same as above *}
{if $name == "Fred" &#124;&#124; $name == "Wilma"}
...
{/if}

{* the following syntax will NOT work, conditional qualifiers
must be separated from surrounding elements by spaces *}
{if $name=="Fred" &#124;&#124; $name=="Wilma"}
...
{/if}


{* parenthesis are allowed *}
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
...
{/if}

{* you can also embed php function calls *}
{if count($var) gt 0}
...
{/if}

{* test if values are even or odd *}
{if $var is even}
...
{/if}
{if $var is odd}
...
{/if}
{if $var is not odd}
...
{/if}

{* test if var is divisible by 4 *}
{if $var is div by 4}
...
{/if}

{* test if var is even, grouped by two. i.e.,
0=even, 1=even, 2=odd, 3=odd, 4=even, 5=even, etc. *}
{if $var is even by 2}
...
{/if}

{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
{if $var is even by 3}
...
{/if}

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/1600/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2016-1-26 10:57
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]