Web Engineering: Control Structures & Loops
Web Engineering: Control Structures & Loops
Lecture 20
Control Structures & Loops
(PHP - III)
1
Logical Expression: If Statement
• Format:
if (expression)
statement;
• Example:
if ($a > $b)
echo “a is larger than b”;
• or (if you have more than one line of code)
}
?>
LOOPS
• Loops allow us to execute the code until
the condition is satisfied. There are three
main kinds of loops:
• while Loops
• for Loops
• foreach Loops
WHILE LOOPS
• The format of while loops is as under:
while (expression)
statement;