Bug #52643 [Opn]: No error/warning for data after missing semicolon after break statement
Edit report at http://bugs.php.net/bug.php?id=52643&edit=1
ID: 52643
Updated by: johannes@php.net
Reported by: haakon dot nessjoen at gmail dot com
Summary: No error/warning for data after missing semicolon
after break statement
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: 5.2.14
Block user comment: N
New Comment:
break may have a parameter. In your case it is the return value of
$variable1 = 'hey'; which is the string 'hey'
Previous Comments:
------------------------------------------------------------------------
[2010-08-19 10:42:01] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52643&edit=1
Thread (3 messages)