|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-12-19 16:07 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 05:00:01 2025 UTC |
? $test = 'c'; switch($test) { case 'c' : print('cccc'); case 'd' : print('dddd'); default: print('problem'); } ?> expected output: cccc actual output: ccccddddproblem Debian Sid GNU/Linux php4 version 4.3.3-5