3v4l.org

run code in 300+ PHP versions simultaneously
<?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"; } } $myInstance = new MyClass(); $myInstance-> iterate_multidim_array($test_data3); ?>
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 20 one Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 20 two Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 20 three Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 20 four Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 20 five Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 20 six
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 22 one Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 22 two Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 22 three Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 22 four Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 22 five Warning: myClass::{closure}(): Argument #3 ($obj) must be passed by reference, value given in /in/B8FU9 on line 22 six
Output for 5.3.0 - 5.3.2, 5.3.11 - 5.3.29, 5.4.1 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.21, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
one two three four five six
Output for 5.3.3 - 5.3.10, 5.4.0
one two three Fatal error: Call to a member function show_message() on a non-object in /in/B8FU9 on line 21
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/B8FU9 on line 20
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/B8FU9 on line 20
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/B8FU9 on line 20
Process exited with code 255.

preferences:
241.33 ms | 401 KiB | 343 Q