From:             cjlars at users dot sourceforge dot net
Operating system: Linux 2.4.21 (only one tested)
PHP version:      4.3.10
PHP Bug Type:     Scripting Engine problem
Bug description:  foreach fails on arrays of objects

Description:
------------
The below code should obviously return "aaaaaaa". With PHP 4.3.10 is
returns nothing.
It does return the expected result if I use:
 foreach ($arr_test as $key => $objtest)
I think in the code below $objtest is an array instead of being an
onject.

This is critical and it affects lots of existing code (I've seen NuSOAP
affected for example)

Reproduce code:
---------------
<?php

class test_class
{
    var $test;
}

$arr_test = array();
$obj = new test_class();
$obj->test = "aaaaaa";
$arr_test[] = $obj;

foreach ($arr_test as $objtest)
    echo $objtest->test;

?>

Expected result:
----------------
aaaaaa

Actual result:
--------------
Nothing

-- 
Edit bug report at http://bugs.php.net/?id=31205&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31205&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31205&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31205&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31205&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31205&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31205&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31205&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31205&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31205&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31205&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31205&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31205&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31205&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31205&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31205&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31205&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31205&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31205&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31205&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31205&r=mysqlcfg

Reply via email to