$if
Checks An expression and executes code Only if that expression is true
Shortest Syntax
$if[EXPRESSION]
CODE
$endIf
What is expression?
Read about it here
Example 1 only with $if
Since the username of the executor is Tom it executed the if block
Example 2 only with $if and $else
Since the username is not Tom it executes the else block
Example 3 $if , $else and $elseif
Since the username is not Tom .It goes to the next if statement ,which is $elseif[$username==Lisa] and it will execute it
Example 4 $if , $else and $elseif
Since the username is not Tom .It goes to the next if statement ,which is $elseif[$username==Lisa] and it will execute it
Info: The second else if will get never executed ,because it will exit the statement after the first true expression
Example 5 multiplie condtions in if with && or ||
Expression can accept multiple conditions, use ||
or &&
as separators
||
is for OR
&&
is for AND
Example:
$username==Mido&&$country==Egypt
Condition 1: $username==Mido
Condition 2: $country==Egypt
But this expression will only be true only if both condition 1 AND (because of &&) condition 2 is true
The Example below will execute since $username==Tom is false but the second expression is true .It wouldn't work with &&
The Example will only execute if the username is Lisa and their tag is 9999