mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Addresses Bug #45223
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@261602 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
220dd8e180
commit
5e8a61948c
1 changed files with 40 additions and 2 deletions
|
@ -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 @@ if ($a > $b) {
|
|||
</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 @@ if ($a > $b) {
|
|||
<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">
|
||||
|
|
Loading…
Reference in a new issue