smarty邏輯運算子號總結_PHP教程

來源:互聯網
上載者:User
很久沒有使用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模板引擎做的,改著改著有些地方...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.