Home > Backend Development > PHP Tutorial > smart flash recovery php Smarty character comparison code

smart flash recovery php Smarty character comparison code

WBOY
Release: 2016-07-29 08:44:32
Original
960 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 used to find the module.
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 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 the template engine. if must appear in pairs with /if. You can use else and elseif clauses. 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 separated from variables or constants 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}

The above introduces the smart flash recovery php Smarty character comparison code, including the content of smart flash recovery. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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