foreach

(PHP 4, PHP 5, PHP 7) Examples: The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. There are two syntaxes: foreach (array_expression as $value) statement foreach (array_expression as $key => $value) st

break

(PHP 4, PHP 5, PHP 7) Examples: break ends execution of the current for, foreach, while, do-while or switch structure. break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of. The default value is 1, only the immediate enclosing structure is broken out of. <?php $arr = array('one', 'two', 'three', 'four', 'stop', 'five

continue

(PHP 4, PHP 5, PHP 7) Examples: continue is used within looping structures to skip the rest of the current loop iteration and continue execution at the condition evaluation and then the beginning of the next iteration. Note: In PHP the switch statement is considered a looping structure for the purposes of continue. continue behaves like break (when no arguments are passed). If a switch

switch

(PHP 4, PHP 5, PHP 7) Examples: switch structure The following two examples are two different ways to write the same thing, one using a series of if and elseif statements, and the other using the switch statement: <?php if ($i == 0) {     echo "i equals 0"; } elseif ($i == 1) {     echo "i equals 1"; } elseif ($i == 2) {     echo "i equals 2"; } switch ($i) {     case 0:         ech

declare

(PHP 4, PHP 5, PHP 7) Examples: The declare construct is used to set execution directives for a block of code. The syntax of declare is similar to the syntax of other flow control constructs: declare (directive) statement As directives are handled as the file is being compiled, only literals may be given as directive values. Variables and constants cannot

return

(PHP 4, PHP 5, PHP 7)

require

(PHP 4, PHP 5, PHP 7)

include

(PHP 4, PHP 5, PHP 7) Examples: Basic include example The include statement includes and evaluates the specified file. The documentation below also applies to require. Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in the include_path, include will finally check in the calling script's own directory and the curr

require_once

(PHP 4, PHP 5, PHP 7)

include_once

(PHP 4, PHP 5, PHP 7) Examples: include_once with a case insensitive OS in PHP 4 With PHP 4, _once functionality differs with case-insensitive operating systems (like Windows) so for example: <?php include_once "a.php"; // this will include a.php include_once "A.php"; // this will include a.php again! (PHP 4 only) ?>