php Smarty character comparison code_PHP tutorial

WBOY
Release: 2016-07-21 15:32:10
Original
921 people have browsed it

eq is equal,
ne and neq are not equal,
gt is greater than,
lt is less than,
gte and ge are greater than or equal to,
lte and le are less than or equal to,
not is not, mod is found mold.
is [not] whether div by is divisible by a certain number,
is [not] even whether it is an even number,
$a is [not] even by $b, that is ($a / $b) % 2 == 0,
is [not] odd whether it is odd,
$a is not odd by $b, that is ($a / $b) % 2 != 0 Example:
equal/ not equal / greater than/ less than/ less than or equal/ great than or equal/ Needless to say the following
The if statement in Smarty is as flexible and easy to use as the if statement in PHP, and has added several features to suit Template engine. if must appear in pairs with /if. Else and elseif clauses can be used. The following conditional modifiers can be used: 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, ==, !=, >, <, <=, >=. These modifiers must be used with variables Or constants are separated by spaces.

Example 7-11. if statements
Example 7-11. if statement demonstration

{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}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322897.htmlTechArticleeq is equal, ne and neq are not equal, gt is greater than lt is less than, gte and ge are greater than or equal to, lte and le Less than or equal to, not, mod. is [not] Is div by divisible by a certain number? is [not]...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!