很久沒有使用Smarty做項目了,今天突然要改改自己的網站裡面的一些東西,因為我網站是很久以前用smarty模板引擎做的,改著改著有些地方就感覺還得網上搜答案了,看來對久違的smarty已經開始生疏了,趕緊補習一下。對Smarty模板的邏輯運算子號稍微做一下總結,以備後用。
eq equal : 相等
neq not equal:不等於
gt greater than:大於
lt less than:小於
lte less than or equal:小於等於
gte great than or equal:大於等於
is even: 是偶數
is odd: 是奇數
is not even: 不是偶數
is not odd 不是奇數
not: 非
mod: 求模取餘
div by: 被。。。除
&& and : 並且
|| or : 或者
is [not] div by 是否能被某數整除,例如:{if $smarty.get.age is div by 3}...{/if}
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!==''} 是判斷變數等不等於空....
Smarty 中的 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、==、!=、>、<、<=、>= 這些邏輯運算子號的時候必須和變數或常量用空格格開。
您可能感興趣的文章
- js限制只能輸入英文字母和數字,不能輸入中文和其他特殊字元的辦法
- smarty模板保留變數總結
- smarty變數操作符總結
- smarty include file 使用變數的方法
- smarty視頻教程分享
- Mysql查詢帶單引號字串及插入帶單引號字串需要注意問題
- smarty模板中使用php函數以及smarty模板中如何對一個變數使用多個函數
- php用header()實現檔案下載,下載的檔案提示被破壞不能開啟的解決辦法
http://www.bkjia.com/PHPjc/764127.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/764127.htmlTechArticle很久沒有使用Smarty做項目了,今天突然要改改自己的網站裡面的一些東西,因為我網站是很久以前用smarty模板引擎做的,改著改著有些地方...