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

From: Date: Mon, 23 Jun 2014 23:57:54 +0000
Subject: Bug->Doc #67504 [Opn]: 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-11305@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 -Type: Bug +Type: Documentation Problem -Package: *General Issues +Package: Documentation problem Operating System: Ubuntu 14.04 PHP Version: 5.5.13 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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 (#11305) next »