热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

eq相等ne、neq不相等,gt大于,lt小于gte、ge大于等于lte、le小于等于not非mod求模等...

eq相等ne、neq不相等,gt大于,lt小于gte、ge大于等于lte、le小于等于not非mod求模is[not]divby是否能被某数整除is[n

eq相等   ne、neq不相等,   gt大于, lt小于 gte、ge大于等于   lte、le 小于等于   not非   mod求模   is [not] div by是否能被某数整除   is [not] even是否为偶数   is [not] even by $b即($a / $b) % 2 == 0   is [not] odd是否为奇   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 语句一样灵活易用&#xff0c;并增加了几个特性以适宜模板引擎. if 必须于 /if 成对出现. 可以使用 else 和 elseif 子句. 可以使用以下条件修饰词&#xff1a;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、&#61;&#61;、!&#61;、>、<、<&#61;、>&#61;. 使用这些修饰词时必须和变量或常量用空格格开.

Example 7-11. if statements

例 7-11. if 语句演示

{if $name eq "Fred"}

Welcome Sir.

{elseif $name eq "Wilma"}

Welcome Ma&#39;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 &#61;&#61; "Fred" || $name &#61;&#61; "Wilma"}

...

{/if}

{* the following syntax will NOT work, conditional qualifiers

must be separated from surrounding elements by spaces *}

{if $name&#61;&#61;"Fred" || $name&#61;&#61;"Wilma"}

...

{/if}

{* parenthesis are allowed *}

{if ( $amount <0 or $amount > 1000 ) and $volume >&#61; #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&#61;even, 1&#61;even, 2&#61;odd, 3&#61;odd, 4&#61;even, 5&#61;even, etc. *}

{if $var is even by 2}

...

{/if}

{* 0&#61;even, 1&#61;even, 2&#61;even, 3&#61;odd, 4&#61;odd, 5&#61;odd, etc. *}

{if $var is even by 3}

...

{/if}

转:https://www.cnblogs.com/langtianya/p/4704957.html



推荐阅读
author-avatar
tina1314520hqg_552
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有