svn: /phpdoc/en/trunk/language/control-structures/ alternative-syntax.xml
| From: | Adam Harvey | Date: | Tue, 24 Jun 2014 00:08:23 +0000 |
| Subject: | svn: /phpdoc/en/trunk/language/control-structures/ alternative-syntax.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-12544@lists.php.net to get a copy of this message | ||
aharvey Tue, 24 Jun 2014 00:08:23 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=333913
Log:
Add a cautionary note about switch/case and whitespace.
Fixes doc bug #67504 (Alternative switch syntax - error when case not in same
block with switch).
Bug: https://bugs.php.net/67504 (Open) Alternative switch
syntax - error when case not in same block with switch
Changed paths:
U phpdoc/en/trunk/language/control-structures/alternative-syntax.xml
Modified: phpdoc/en/trunk/language/control-structures/alternative-syntax.xml
===================================================================
--- phpdoc/en/trunk/language/control-structures/alternative-syntax.xml 2014-06-23 17:59:07 UTC (rev
333912)
+++ phpdoc/en/trunk/language/control-structures/alternative-syntax.xml 2014-06-24 00:08:23 UTC (rev
333913)
@@ -57,6 +57,39 @@
Mixing syntaxes in the same control block is not supported.
</para>
</note>
+ <warning>
+ <para>
+ Any output (including whitespace) between a <literal>switch</literal>
+ statement and the first <literal>case</literal> will result in a syntax
+ error. For example, this is invalid:
+ </para>
+ <informalexample>
+ <programlisting role="php">
+<![CDATA[
+<?php switch ($foo): ?>
+ <?php case 1: ?>
+ ...
+<?php endswitch ?>
+]]>
+ </programlisting>
+ </informalexample>
+ <para>
+ Whereas this is valid, as the trailing newline after the
+ <literal>switch</literal> statement is considered part of the closing
+ <literal>?></literal> and hence nothing is output between the
+ <literal>switch</literal> and <literal>case</literal>:
+ </para>
+ <informalexample>
+ <programlisting role="php">
+<![CDATA[
+<?php switch ($foo): ?>
+<?php case 1: ?>
+ ...
+<?php endswitch ?>
+]]>
+ </programlisting>
+ </informalexample>
+ </warning>
<para>
See also <link linkend="control-structures.while">while</link>,
<link linkend="control-structures.for">for</link>, and <link