From 5e8a61948c4da590d55d0f9e65ff2c7dfafd0bb6 Mon Sep 17 00:00:00 2001 From: "Daniel P. Brown" Date: Tue, 24 Jun 2008 18:51:19 +0000 Subject: [PATCH] Addresses Bug #45223 git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@261602 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/control-structures.xml | 42 +++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/language/control-structures.xml b/language/control-structures.xml index 5a40f805d0..561681bff8 100644 --- a/language/control-structures.xml +++ b/language/control-structures.xml @@ -1,5 +1,5 @@ - + Control Structures @@ -126,7 +126,7 @@ if ($a > $b) { - <literal>elseif</literal> + <literal>elseif</literal>/<literal>else if</literal> elseif, as its name suggests, is a combination of if and else. Like @@ -175,6 +175,44 @@ if ($a > $b) { elseif expression evaluated to &true;. + + + Note that elseif and else if + will only be considered exactly the same when using curly brackets + as in the above example. When using a colon to define your + if/elseif conditions, you must + separate else if into two words, or PHP will + fail with a parse error. + + + + + + $b): + echo $a." is greater than ".$b; +else if($a == $b): // Will not compile. + echo "The above line causes a parse error."; +endif; + + +/* Correct Method: */ +if($a > $b): + echo $a." is greater than ".$b; +elseif($a == $b): // Note the combination of the words. + echo $a." equals ".$b; +else: + echo $a." is neither greater than or equal to ".$b; +endif; + +?> +]]> + + +