php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52643 No error/warning for data after missing semicolon after break statement
Submitted: 2010-08-19 10:42 UTC Modified: 2010-08-20 07:22 UTC
From: haakon dot nessjoen at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.14 OS: Linux
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: haakon dot nessjoen at gmail dot com
New email:
PHP Version: OS:

 

 [2010-08-19 10:42 UTC] haakon dot nessjoen at gmail dot com
Description:
------------
If you forget the semicolon after a 'break' statement. Almost all characters up to the next ; is ignored. Hence you won't get a error message about the problem.

For example, if you set a variable immediately after a mistake like this. You might be wondering for a long time of why the variable is not set.

Test script:
---------------
<?

if (0)
 break

$variable1 = 'hey';
$variable2 = 'ho';

print "Variable1 = $variable1\n";
print "Variable2 = $variable2\n";

?>

Expected result:
----------------
Error message

Actual result:
--------------
Variable1 = 
Variable2 = ho

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-19 18:28 UTC] johannes@php.net
break may have a parameter. In your case it is the return value of $variable1 = 'hey'; which is the string 'hey'
 [2010-08-20 07:22 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2010-08-20 07:22 UTC] aharvey@php.net
I suspect Johannes meant to close this. :)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 04 07:00:01 2025 UTC