Any PHP script is built out of a series of statements. A statement can be an assignment, a function call, a loop, a conditional statement or even a statement that does nothing (an empty statement). Statements usually end with a semicolon. The various statement types are described in this chapter
if
<?phpif ($a > $b) {
echo "a is greater than b";
} else {
echo "a is NOT greater than b";
}?>
If expression evaluates to TRUE, PHP will execute statement, and if it evaluates to FALSE - it'll ignore it. More information about what values evaluate to FALSE can be found in the 'Converting to boolean' section.
if
<?phpif ($a > $b) {
echo "a is greater than b";
} else {
echo "a is NOT greater than b";
}?>
If expression evaluates to TRUE, PHP will execute statement, and if it evaluates to FALSE - it'll ignore it. More information about what values evaluate to FALSE can be found in the 'Converting to boolean' section.
Alternative syntax for control structures
<?php if ($a == 5): ?>A is equal to 5
<?php endif; ?>
Comments
Post a Comment