php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17721 Braindead error for malformed switch statement
Submitted: 2002-06-12 01:36 UTC Modified: 2002-06-12 01:59 UTC
From: kims at contrail dot com dot au Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0CVS-2002-06-11 OS: Debian GNU/Linux
Private report: No CVE-ID: None
 [2002-06-12 01:36 UTC] kims at contrail dot com dot au
When one forgets to the closing curly bracket ("}") in a switch statement, php gives an error of:

Parse error: parse error, unexpected $ in /home/kims/switch.php on line n

(where n is the numer of lines in the script).

This error is completely unhelpful. The error should, at a minimum, report that the problem is an "unterminated switch" or a "missing }".

Even better, would be "unterminated switch (starting on line n)", or "missing } after last case" or something.

Here's a script that causes this error:

<?
	switch ('foo')
	{
		default:
			echo "Hello World!\n";

	/* uncomment to make this work */
//	}
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-12 01:59 UTC] mfischer@php.net
The engine can't and won't catch every user stupidity out there.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 18:00:02 2026 UTC