From:             kobieta dot ryba at gmail dot com
Operating system: Linux
PHP version:      6CVS-2009-01-07 (CVS)
PHP Bug Type:     Scripting Engine problem
Bug description:  Strange foreach behavior when using references

Description:
------------
I've noticed strange behavior when using references and foreach loop. 
It throws an error "Invalid argument supplied for foreach" but if the
code
// $ass = &$array;
is commented out, the result is as expected:
Output:
in
in
in


Reproduce code:
---------------
<?
$array = array("1", "2", "3");
$ass = &$array;
foreach($array as $k => &$v)
{
  $array = false;

  $v = "Test";
  echo "in\n";
}
?>

Expected result:
----------------
in
in
in


Actual result:
--------------
in

Warning: Invalid argument supplied for foreach() in test.php on line 5


-- 
Edit bug report at http://bugs.php.net/?id=47028&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47028&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47028&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47028&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47028&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47028&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47028&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47028&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47028&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47028&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47028&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47028&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47028&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47028&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47028&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47028&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47028&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47028&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47028&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47028&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47028&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47028&r=mysqlcfg

Reply via email to