PHP Commands


PHP Tutorial > 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 ... WHILE

DO {
  [code to execute]
} WHILE (conditional statement)

ELSEIF

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 Loop

FOR (expression 1, expression 2, expression 3)
{
  [code to execute]
}

FOREACH Loop

FOREACH ($array_variable as $value)
{
  [code to execute]
}
or
FOREACH ($array_variable as $key => $value)
{
  [code to execute]
}

IF ELSE

IF (conditional statement) {
  [code if condition is true]
}
ELSE {
  [code if condition is false]
}

Include

INCLUDE ("external_file_name");

SWITCH ($variable) {
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']
}

WHILE Loop

WHILE (expression)
{
  [code to execute]
}

Next: Resources

Link to this page: If you find this page useful, we encourage you to link to this page. Simply copy and paste the code below to your website, blog, or profile.






Copyright 1keydata.com 2007, 2008, All Rights Reserved.   Privacy Policy  



PHP Tutorial
PHP Variables
PHP Operators
PHP IF ELSE
PHP ELSEIF
PHP Switch
PHP While Loop
PHP FOR Loop
PHP DO WHILE Loop
PHP FOREACH Loop
PHP INCLUDE
PHP Functions
PHP ARRAY
PHP FORMS
PHP Cookies
PHP Redirect
PHP MySQL

PHP Commands

Resources