Doc #67504 [Opn->Csd]: Alternative switch syntax - error when case not in same block with switch

From: Date: Tue, 24 Jun 2014 00:08:29 +0000
Subject: Doc #67504 [Opn->Csd]: Alternative switch syntax - error when case not in same block with switch
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-11306@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67504&edit=1 ID: 67504 Updated by: aharvey@php.net Reported by: lightnb at bellsouth dot net Summary: Alternative switch syntax - error when case not in same block with switch -Status: Open +Status: Closed Type: Documentation Problem Package: Documentation problem Operating System: Ubuntu 14.04 PHP Version: 5.5.13 -Assigned To: +Assigned To: aharvey Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2014-06-24 00:08:24] aharvey@php.net Automatic comment from SVN on behalf of aharvey Revision: http://svn.php.net/viewvc/?view=revision&amp;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). ------------------------------------------------------------------------ [2014-06-23 23:57:54] aharvey@php.net This works OK without the indentation (cf http://3v4l.org/Lj7L7): the issue is that the indentation before the case statement effectively puts an echo in between the switch and the case, which is invalid. I'll see if I can tighten up the alternative syntax documentation to mention that. ------------------------------------------------------------------------ [2014-06-23 23:48:23] lightnb at bellsouth dot net Description: ------------ My actual version is 5.5.9-1ubuntu4, it wasn't on the list. This is the Ubuntu package version on Ubuntu 14.04. The following code throws a parse error on the second line. The error is: "syntax error, unexpected ' ', expecting endswitch (T_ENDSWITCH) or case (T_CASE) or default (T_DEFAULT)" <?switch($MyVar):?> <?case '1':?> Step One <?break;?> <?case '2':?> Step Two <?break;?> <?endswitch;?> It appears that the closing tag trips up the parser which it should not do when using the alternative switch syntax. Using the following syntax (putting the first case in the same PHP block as the opening switch) works correctly: <?switch($MyVar): case '1':?> Step One <?break;?> <?case '2':?> Step Two <?break;?> <?endswitch;?> Test script: --------------- <?switch($MyVar):?> <?case '1':?> Step One <?break;?> <?case '2':?> Step Two <?break;?> <?endswitch;?> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67504&edit=1

« previous php.doc.bugs (#11306) next »