Bug #67504 [NEW]: Alternative switch syntax - error when case not in same block with switch
| From: | lightnb at bellsouth dot net | Date: | Mon, 23 Jun 2014 23:48:23 +0000 |
| Subject: | Bug #67504 [NEW]: Alternative switch syntax - error when case not in same block with switch | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186311@lists.php.net to get a copy of this message | ||
From: lightnb at bellsouth dot net
Operating system: Ubuntu 14.04
PHP version: 5.5.13
Package: *General Issues
Bug Type: Bug
Bug description:Alternative switch syntax - error when case not in same block with switch
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 bug report at https://bugs.php.net/bug.php?id=67504&edit=1
--