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 语句一样灵活易用,并增加了几个特性以适宜模板引擎. 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" || $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}

Smarty中模板eq相等 ne、neq不相等, gt大于, lt小于的更多相关文章

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

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

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

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

  3. eq相等 ,ne、neq不相等 EL表达式

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

  4. Smarty的模板中不允许PHP的代码?

    /****************************************************************************** * Smarty的模板中不允许PHP的代 ...

  5. shell中 -eq,-ne,-gt,-lt,-ge,-le数字比较符

    使用说明:     -eq //equals等于    -ne //no equals不等于    -gt //greater than 大于    -lt //less than小于    -ge ...

  6. Java中eq、ne、ge、gt、le、lt的含义

    Java中eq.ne.ge.gt.le.lt 关系运算符包括EQ.NE.GE.GT.LE.LT几个,关系运算符返回的是真"True"或假"False". eq( ...

  7. Perl语言中一些内置变量等,$x、qw、cmp、eq、ne等

    转载 Perl语言中一些内置变量等,$x.qw.cmp.eq.ne等 字母 符号 释义 eq  = = equal(等于) ne != not equal(不等于) cmp 比较 qq  " ...

  8. smarty 中时间格式化的用法

    大家都知道PHP中输出时间和日期可以用 date("Y-m-d H:i:s",时间戳)  , 但是在smarty模板中,$time|date_format:'%Y-%m-%d %H ...

  9. smarty中的修饰函数

    smarty中的修饰函数: 对在模板文件中显示的数据变量进行二次修饰. 格式: {ts:变量|函数名:参数1:参数2:参数3...|函数名:参数1:参数2...} 常见的修饰函数: capitaliz ...

随机推荐

  1. response.sendRedirect 传递参数的问题

    response.sendRedirect是通过浏览器来做转向的. 假设在A.jsp页面设置request.setAttribute("username","admin& ...

  2. 14.1.1 InnoDB as the Default MySQL Storage Engine

    14.1 Introduction to InnoDB 14.1.1 InnoDB as the Default MySQL Storage Engine 14.1.2 Checking InnoDB ...

  3. Solr集群、KI分词、项目实战

    Solr是一个高性能,采用Java开发,基于Lucene的全文搜索服务器.同时对其进行了扩展,提供了比Lucene更为丰富的查询语言,同时实现了可配置.可扩展并对查询性能进行了优化,并且提供了一个完善 ...

  4. git 提交ignore files

    1,首先在命令行创建.gitignore文件 $ touch .gitignore 2,在文件.gitignore 加入要忽略的文件入 $ echo *.class > .gitignore 3 ...

  5. OCA读书笔记(6) - 配置Oracle网络环境

    6.Configuring the Oracle Network Environment su - grid装grid时自动创建了监听netca--创建新的监听 vi $ORACLE_HOME/net ...

  6. T-SQL 操作文件 具体解释

    /*******  导出到excel EXEC master..xp_cmdshell 'bcp SettleDB.dbo.shanghu out c:\temp1.xls -c -q -S" ...

  7. Oauth认证的时候报错:timestamp_refused

    今天server大规模报错,大部分用户无法登陆,小部分能够登陆,非常是奇怪. 查看log.调试代码,发现问题是在oauth认证的时候出了问题,报 timestamp_refused. google了下 ...

  8. Swift - 多行文本输入框(UITextView)的用法

    1,多行文本控件的创建 1 2 3 4 var textview=UITextView(frame:CGRectMake(10,100,200,100)) textview.layer.borderW ...

  9. wiki 3143 二叉树的前序、中序及后序遍历

    先序遍历:訪问根.遍历左子树.遍历右子树,简称:DLR. 中序遍历:遍历左子树,訪问根,遍历右子树,简称:LDR. 后序遍历:遍历左子树,遍历右子树.訪问根.简称:LRD. 数组搞的: #pragma ...

  10. 注册Dev的帮助文件

    Download the CHM files from… Code: https://www.devexpress.com/Support/Documentation/download.xml?pla ...