cvs: phpdoc /en/language control-structures.xml
| From: | Daniel P. Brown | Date: | Tue, 24 Jun 2008 18:51:19 +0000 |
| Subject: | cvs: phpdoc /en/language control-structures.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-1795@lists.php.net to get a copy of this message | ||
danbrown Tue Jun 24 18:51:19 2008 UTC
Modified files:
/phpdoc/en/language control-structures.xml
Log:
Addresses Bug #45223
http://cvs.php.net/viewvc.cgi/phpdoc/en/language/control-structures.xml?r1=1.161&r2=1.162&diff_format=u
Index: phpdoc/en/language/control-structures.xml
diff -u phpdoc/en/language/control-structures.xml:1.161
phpdoc/en/language/control-structures.xml:1.162
--- phpdoc/en/language/control-structures.xml:1.161 Fri Apr 18 19:49:43 2008
+++ phpdoc/en/language/control-structures.xml Tue Jun 24 18:51:19 2008
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.161 $ -->
+<!-- $Revision: 1.162 $ -->
<chapter xml:id="language.control-structures" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Control Structures</title>
@@ -126,7 +126,7 @@
</sect1>
<sect1 xml:id="control-structures.elseif">
- <title><literal>elseif</literal></title>
+ <title><literal>elseif</literal>/<literal>else
if</literal></title>
<para>
<literal>elseif</literal>, as its name suggests, is a combination
of <literal>if</literal> and <literal>else</literal>. Like
@@ -175,6 +175,44 @@
<literal>elseif</literal> expression evaluated to
&true;.
</simpara>
+ <note>
+ <simpara>
+ Note that <literal>elseif</literal> and <literal>else if</literal>
+ will only be considered exactly the same when using curly brackets
+ as in the above example. When using a colon to define your
+ <literal>if</literal>/<literal>elseif</literal> conditions, you must
+ separate <literal>else if</literal> into two words, or PHP will
+ fail with a parse error.
+ </simpara>
+ </note>
+ <para>
+ <informalexample>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+/* Incorrect Method: */
+if($a > $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;
+
+?>
+]]>
+ </programlisting>
+ </informalexample>
+ </para>
</sect1>
<sect1 xml:id="control-structures.alternative-syntax">