PHP Commands |
This pages lists common PHP commands and their respective syntax. To view details on each command, please click on the link; to learn PHP from the beginning, please go to the PHP Tutorial homepage.
DO {
[code to execute]
} WHILE (conditional statement)
IF (conditional statement 1) {
[code if condition statement 1 is true]
}
ELSEIF (conditional statement 2) {
[code if condition statement 2 is true]
}
ELSE {
[code if neither statement is true]
}
FOR (expression 1, expression 2, expression 3)
{
[code to execute]
}
FOREACH ($array_variable as $value)
IF (conditional statement) {
INCLUDE ("external_file_name");
SWITCH ($variable) {
WHILE (expression)
{
[code to execute]
}
or
FOREACH ($array_variable as $key => $value)
{
[code to execute]
}
[code if condition is true]
}
ELSE {
[code if condition is false]
}
CASE 'value 1':
[code to execute when $variable = 'value 1']
break;
CASE 'value 2':
[code to execute when $variable = 'value 2']
break;
CASE 'value 3':
...
DEFAULT:
[code to execute when none of the CASE values matches $variable']
}
{
[code to execute]
}