#26671 [Opn->Fbk]: SWITCH fails when DEFAULT statement included
| From: | derick@php.net | Date: | Sat, 20 Dec 2003 14:07:46 +0000 |
| Subject: | #26671 [Opn->Fbk]: SWITCH fails when DEFAULT statement included | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-52343@lists.php.net to get a copy of this message | ||
ID: 26671
Updated by: derick@php.net
Reported By: memoimyself at yahoo dot com dot br
-Status: Open
+Status: Feedback
Bug Type: Scripting Engine problem
Operating System: Windows 2000 SP 4
PHP Version: 4.3.4
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
Can you see if it's fixed in this one?
Previous Comments:
------------------------------------------------------------------------
[2003-12-20 09:01:46] memoimyself at yahoo dot com dot br
Yes, I am positive. In fact, I was getting this error when debugging a
class I'd written. I then created a simple test script (which I posted
here) by typing (not by copying and pasting) everything again, and the
error came up again. If I comment out the "default:" line, everything
works well. Damned if I know what's going on. :-)
------------------------------------------------------------------------
[2003-12-19 18:43:08] eru@php.net
Works fine for me, same system:
D:\PHP>php test.php
Content-type: text/html
X-Powered-By: PHP/4.3.4
a
D:\PHP>
Are you sure, that you don't have some control-character or anything
like that in your code? Please retest.
------------------------------------------------------------------------
[2003-12-19 16:07:32] memoimyself at yahoo dot com dot br
Description:
------------
The "switch" statement fails when a "default" case is included, as in
the example below. It makes no difference if there's a "break" at the
end of the default case.
I'm not leaving out any parentheses, braces or semi-colons. In fact,
all you need to do in order to get the switch statement below to work
is comment out the last two lines before the closing brace.
Reproduce code:
---------------
$test = 'a';
switch ($test)
{
case 'a':
print 'a';
break;
case 'b':
print 'b';
break;
default:
print 'neither';
}
Expected result:
----------------
String 'a' should be printed on screen.
Actual result:
--------------
Parse error: parse error, unexpected T_DEFAULT in
D:\htdocs\Test\test.php on line 12
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26671&edit=1