php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33287 foreach does not give errors
Submitted: 2005-06-09 22:11 UTC Modified: 2005-08-13 13:37 UTC
From: chris at deskpro dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.3.11 OS: Win/MacOS linux untested
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: chris at deskpro dot com
New email:
PHP Version: OS:

 

 [2005-06-09 22:11 UTC] chris at deskpro dot com
Description:
------------
This is a repost of 33264

33264 was closed because it was said the bug is the same 
as 31114. They are however completly different.

31114 is about foreach where the $key and $value are the 
same:
foreach ($array AS $key => $key)
which should, perhaps issue a warning.

However, 33264 is about foreach not issuing an error 
when you try and loop on an unset variable or a string 
e.g.:

$array = '';
foreach ($array AS $value) {

this should, and used to issue an error (I think it was 
fatal). It not longer does.

The manual even suggests this error is not preventable 
with a @, but not it dosen't appear at all.

So this is both a real bug and important.

Reproduce code:
---------------
<?php
error_reporting(E_ALL);
foreach ($a AS $b) {
}
?>

Expected result:
----------------
Error about $a not being an array.

Actual result:
--------------
No error.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2005-08-13 11:44 UTC] ondrej at sury dot org
Bug is fixed in php 4.4.0.
 [2005-08-13 13:37 UTC] tony2001@php.net
Marking as closed then.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Sep 29 01:01:26 2024 UTC