前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ecshop中smarty比较操作符(eq,ne,neq)含义

ecshop中smarty比较操作符(eq,ne,neq)含义

作者头像
Yiiven
发布2022-12-15 11:39:46
1.1K0
发布2022-12-15 11:39:46
举报
文章被收录于专栏:怡文菌

说明

eq

等于

equal

ne,neq

不等于

not equal

gt

大于

greater than

lt

小于

less than

get,ge

大于等于

great than or equal

lte,le

小于等于

less than or equal

not

mod

取余

is not div

是否能被整除

$a is not div by $b即$a%$b==0

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

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、==、!=、>、<、<=、>=。

使用这些修饰词时必须和变量或常量用空格格开。

例. 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” || $name == “Wilma”}

{/if}

{* the following syntax will NOT work, conditional qualifiers

must be separated from surrounding elements by spaces *}

{if $name==”Fred” || $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}

本文采用 「CC BY-NC-SA 4.0」创作共享协议,转载请标注以下信息:

原文出处:Yiiven https://cloud.tencent.com/developer/article/2193076

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017-07-13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档