IF...ELSE
Conditional statements, tells the program to perform a certain instruction depending on the given condition.
IF
Executes the statement only if the condition is TRUE.
IF (condition) {
statement
}
ELSE
Executes the alternate statement only if the condition is FALSE.
IF (condition) {
statement
} ELSE {
alternate statement
}
ELSEIF
Executes the alternate statement only if the alternate condition of the ELSEIF is TRUE.
IF (condition) {
statement
} ELSEIF (alternate condition) {
alternate statement
}
Example
$x = 1
$y = 2
IF ($x > $y) {
$result = "X is bigger than Y"
} ELSEIF ($x === $y) {
$result = "X is equal to Y"
} ELSE {
$result = "X is smaller than Y"
}
$result
play_arrow RUN open_in_new OPEN IN TAB
Copyright ©2013-2022 SunSed®. All rights reserved.