| Use | Syntax | Example |
| Decide whether or not to do something | if (test) statement | if ($e = 1) print ("hello"); |
| Do this if the If conditions are not met | else statement | if ($e = 1) print ("hello"); else print ("goodbye"); |
| if the if conditions are met, do something.
otherwise, check if the elseif conditions are met.
if neither of them are met, do the else condition. | if (condition) {do something}; elseif (condition)
{do something else}; else {do something different}; | if ($e = 1) print ("hello"); elseif ($e = 2) print
("goodbye"); else print ("ERROR"); |
| Do a loop x amount of times. | for (x=1;x<5;X++){do something} | for (x=1; x<5; X++;){print "Hello"} |
| Do a loop once for every item in an array. | foreach(Array name as variable) {do something} | foreach($pagedata as $row){
print(" |
");
| Do a loop repeatedly as long as a variable is true | $i = 0;
do {
echo $i;
} while ($i > 0); | $i = 0;
do {
echo $i;
} while ($i > 0);
|