Smarty if Operator

Source: Internet
Author: User
In smarty If Statement and PHP If Statements are flexible and easy to use, and several features are added to fit the template engine. If Required/ If Appear in pairs. You can use Else And Elseif Clause. you can use the following conditional modifiers: 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, = ,! =,>, <, <=,> =. When using these modifiers, it must be opened with an empty lattice with variables or constants. Equal EQ, not equal to ne, NEQ, GT greater than, Lt less than, GTE, GE greater than or equal to, LTE, le less than or equal to, not, MOD modulo. Is [not] Div by can be divisible by a certain number, is [not] Even is an even number  $ Is [not] even $ B ($ / $ B ) % 2 = 0 , Is [not] whether odd is odd,  $ Is not odd $ B ( $ / $ B ) % 2! = 0 Example: equal /Not equal/greater than/less than or equal/great than or equal/ Not to mention  If Statement and PHP If Statements are flexible and easy to use, and several features are added to fit the template engine. If Required/If Appear in pairs. You can use Else And Elseif Clause. you can use the following conditional modifiers: 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, = ,! =,>, <, <=,> =. When using these modifiers, it must be opened with an empty lattice with variables or constants. Example 7-11. If  Statements example 7-11. If  Statement demo {  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 qualifiersmust 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 CILS *} {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} {if $ _ global_password} indicates that the variable does not exist .... {if $ _ global_password! ='' } Is to judge whether the variable is not equal to null .... the IF statement in smarty is as flexible and easy to use as the if statement in PHP, and several features are added to fit the template engine. if must appear in pairs with/if. else and elseif clauses can be used. you can use the following conditional modifiers: 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, = ,! =,>, <, <=,> =. When using these modifiers, they must be opened with spaces for variables or constants. equal: equal, not equal: not equal to, greater than: greater than, less than: less than, less than or equal: less than or equal to, great than or equal: greater than or equal to, is even: is an even number, is odd: is an odd number, is not even: Not an even number, is not odd: Not an odd number, not: Not, MOD: remainder, div by: Is... The following is a division style: <{if $ count is Div by 4 }></tr> <tr ><{/ if}> 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.