|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
39 + 6 = ?
Subscribe to this entry?

 [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-2023 The PHP Group
All rights reserved.
Last updated: Thu Feb 09 05:05:49 2023 UTC