fenom/docs/operators.md
2013-07-02 11:07:33 +04:00

957 B

Operators

Math

Operators: + - / *

{$a + $b * $c/$d - $e*5 + 1e3}

Boolean

Operators: || && and or < > <= >= == === !== !=

{if $a && $b >= 5 && $c != 3} {/if}

Bitwize

Operators: | & << >> |= &= <<= >>=

{if $a & 1} {var $b |= $flags} {/if}

Unary

Operators: ^ ~ - !

{var $b |= $flags & ^$c}

Ternar

Operators: ? :

{var $a = true}
{$a ? 5 : 10} {* outputs 5 *}
{var $a = false}
{$a ? 5 : 10} {* outputs 10 *}

Variable operator

Checking variable value

{if $a?} {* instead of {if !empty($a)} *}

Checking variable existence

{if $a!} {* instead of {if isset($a)} *}

Get default if variable is empty

{$a?:"some text"} {* instead of {if empty($a) ? "some text" : $a} *}

Get default if variable doesn't exist

{$a!:"some text"} {* instead of {if isset($a) ? $a : "some text"} *}