PhpSmarty character comparison code _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PhpSmarty character comparison code. 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] whether divby can be divisible by a certain number. is [not] eq is equal,
Ne, neq are not equal,
Gt>,
Lt is less,
Gte and ge are greater than or equal,
Less than or equal to lte and le,
Not Non. mod modulo.
Is [not] can p by be divisible by a certain number,
Is [not] Whether the even is an even number,
$ A is [not] even by $ B ($ a/$ B) % 2 = 0,
Is [not] is odd,
$ A is not odd by $ B ($ a/$ B) % 2! = 0 example:
Equal/not equal/greater than/less than or equal/great than or equal/is not required.
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, p 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

{If $ name eq "Fred "}
Welcome Sir.
{Elseif $ name eq "Wilma "}
Welcome m'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 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 pisible by 4 *}
{If $ var is p 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}

Except, ne, neq are not equal, gt is greater than, lt is less than, gte, ge is greater than or equal, lte, le is less than or equal, not, mod modulo. Is [not] can p by be divisible by a certain number? is [not]...

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.