#32670 [Opn->Ver]: foreach sets source variable if not already set and does not issue warning
| From: | sniper@php.net | Date: | Mon, 11 Apr 2005 15:36:37 +0000 |
| Subject: | #32670 [Opn->Ver]: foreach sets source variable if not already set and does not issue warning | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-76646@lists.php.net to get a copy of this message | ||
ID: 32670
Updated by: sniper@php.net
Reported By: cmoore at iyd dot com
-Status: Open
+Status: Verified
Bug Type: Arrays related
-Operating System: Linux
+Operating System: *
-PHP Version: 4.3.11
+PHP Version: 4CVS, 5CVS (2005-04-11)
New Comment:
Result with PHP 4 CVS: nothing
Result with PHP 5 CVS:
Notice: Undefined variable: check in /home/jani/t.php on line 3
Warning: Invalid argument supplied for foreach() in /home/jani/t.php on
line 3
/usr/src/php/php5/Zend/zend_vm_execute.h(18237) : Freeing 0x0968A434
(16 bytes), script=t.php
=== Total 1 memory leaks detected ===
Previous Comments:
------------------------------------------------------------------------
[2005-04-11 16:07:24] cmoore at iyd dot com
Description:
------------
prior versions of php (4.3.10 tested) will issue a warning if an unset
variable is passed to foreach(). even with error_reporting(E_ALL), this
one will not warn. the warning would be nice to see with the same level
of error reporting that if() warns at.
Reproduce code:
---------------
<?
error_reporting(E_ALL);
foreach($check as $test)
;
Expected result:
----------------
Warning: Invalid argument supplied for foreach() in test.php on line 3
Actual result:
--------------
there is no result in 4.3.11
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32670&edit=1