|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26671 SWITCH fails when DEFAULT statement included
Submitted: 2003-12-19 16:07 UTC Modified: 2004-01-01 20:48 UTC
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: memoimyself at yahoo dot com dot br Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 4.3.4 OS: Windows 2000 SP 4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: memoimyself at yahoo dot com dot br
New email:
PHP Version: OS:


 [2003-12-19 16:07 UTC] memoimyself at yahoo dot com dot br
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';
	case 'b':
		print 'b';
		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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-19 18:43 UTC]
Works fine for me, same system:

D:\PHP>php test.php
Content-type: text/html
X-Powered-By: PHP/4.3.4


Are you sure, that you don't have some control-character or anything like that in your code? Please retest.

 [2003-12-20 09:01 UTC] 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-20 09:07 UTC]
Please try using this CVS snapshot:
For Windows:

Can you see if it's fixed in this one?
 [2004-01-01 20:48 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

 [2004-02-04 01:30 UTC] elizabeth at ctyalcove dot org
$test = 'c';

case 'c' :

case 'd' :


expected output:

actual output:

Debian Sid GNU/Linux
php4 version 4.3.3-5
 [2004-02-04 01:33 UTC] elizabeth at ctyalcove dot org
oops, silly me - syntax error - problem fixed :)
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Mar 28 03:03:37 2023 UTC