#33287 [NEW]: foreach does not give errors
| From: | chris at deskpro dot com | Date: | Thu, 09 Jun 2005 20:11:41 +0000 |
| Subject: | #33287 [NEW]: foreach does not give errors | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-80104@lists.php.net to get a copy of this message | ||
From: chris at deskpro dot com
Operating system: Win/MacOS linux untested
PHP version: 4.3.11
PHP Bug Type: Arrays related
Bug description: foreach does not give errors
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.
--
Edit bug report at http://bugs.php.net/?id=33287&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33287&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33287&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33287&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33287&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33287&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33287&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33287&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33287&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33287&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33287&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33287&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33287&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33287&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33287&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33287&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33287&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33287&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33287&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33287&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33287&r=mysqlcfg