Edit report at https://bugs.php.net/bug.php?id=55379&edit=1
ID: 55379
Comment by: reeze dot xia at gmail dot com
Reported by: rsk82 at live dot com
Summary: can't iterate multidimensional array when referring
to an object inside closure
Status: Open
Type: Bug
Package: Class/Object related
Operating System: Windows XP SP3
PHP Version: 5.3.7
Block user comment: N
Private report: N
New Comment:
Hi rsk82,
please try lastest version,
from the follow result,
it it didn't crash on Linux, but the result output changed. so it
might been fixed already.
please refer to: http://3v4l.org/NUtav
Previous Comments:
------------------------------------------------------------------------
[2011-08-19 16:33:19] rsk82 at live dot com
I nowadays released 5.3.7 this bug wasn't repaired.
------------------------------------------------------------------------
[2011-08-07 14:50:33] rsk82 at live dot com
Description:
------------
affected versions:
php-5.3.6-Win32-VC9-x86
php-5.3.7RC4-Win32-VC9-x86
php-5.3-ts-windows-vc9-x86-r314352
php-5.3-ts-windows-vc9-x86-r314419
php-5.4-ts-windows-vc9-x86-r314420
operating system:
Windows XP SP3
description in code
Test script:
---------------
<?php
$test_data1 = array('one','two','three');
// all is ok
$test_data2 = array(array('one','two','three'));
// windows error:
// #The instruction at '<address>' referenced memory at '<address>'.
// #The memory could not be read.
// #Click OK to terminate the program.
// No error shows up in console, sometimes script stops without error but
sometimes executes like nothing is happening.
$test_data3 = array(array('one','two','three'),array('four','five','six'));
// error in PHP console:
// Fatal error: Call to a member function show_message() on a non-object in
c:\scripts\found-error.php on line xx
// values one two three are displayed, four five and six are ommitted.
class myClass {
function iterate_multidim_array($array) {
array_walk_recursive($array,function(&$val,$key,&$obj) {
$obj->show_message($val);
},$this);
}
function show_message($msg) {
echo $msg."\n";
}
}
echo phpversion()."\n\n";
$myInstance = new MyClass();
$myInstance-> iterate_multidim_array($test_data3);
?>
Expected result:
----------------
see no errors
Actual result:
--------------
comments in code
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55379&edit=1