|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22225 Foreach statement allows for unexpected ';' without throwing error.
Submitted: 2003-02-14 13:16 UTC Modified: 2003-02-14 13:22 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ldouglas at whiteiron dot tv Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 4.3.0 OS: Redhat 7.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ldouglas at whiteiron dot tv
New email:
PHP Version: OS:


 [2003-02-14 13:16 UTC] ldouglas at whiteiron dot tv
foreach($someArray AS $index => $key);

Assuming that $someArray has a length greater than 1;  The semi-colon at the end of the foreach() statement does not throw a syntax error and it also does not loop through the instructions, rather it runs the instructions once with what would be the 'last' set of $key


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-14 13:22 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Imagine the following case:

if (true); // if statement is terminated by a semicolon.
/* blah */
 // this block has nothing to do with the above statement

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 21 19:01:29 2024 UTC