Unit-2-Lecture-4-Controlling-Program-Flow
Unit-2-Lecture-4-Controlling-Program-Flow
COMP203TH
Unit-II
Lecture: 4
Controlling Program Flow
(PHP Conditional events and loops)
The if Statement:
simplest conditional statement.
if X happens, do Y.
e.g. below example contains a conditional statement that checks if the
value of the $number variable is less than 0 and prints a notification
message if so.
Syntax:
Once PHP finds a case statement that evaluates to true, it executes not
only the code the code corresponding to that case statement, but also the
code for all subsequent case statements.
If this is not what you want, add a break statement to the end of each
case block to tell PHP to break out of the switch-case statement block
once it executes the code corresponding to the first true case.