May 2016
Intermediate to advanced
155 pages
2h 15m
English
© Mikael Olsson 2016
Mikael Olsson, PHP 7 Quick Scripting Reference, 10.1007/978-1-4842-1922-5_6
Mikael Olsson1
(1)Hammarland, Finland
Conditional statements are used to execute different code blocks based on different conditions.
The if statement only executes if the condition inside the parentheses is evaluated to true. The condition can include any of the comparison and logical operators. In PHP, the condition does not have to be a Boolean expression.
if ($x == 1) {echo "x is 1";}
To test for other conditions, the if statement can be extended with any number of elseif clauses. Each additional condition is only tested if all previous conditions are false.
elseif ($x == 2) {echo "x is 2";}
For handling all other cases, ...
Read now
Unlock full access