3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Test1 extends ArrayObject { } class Test2 extends ArrayObject { function offsetGet($key) { return parent::offsetGet($key); } } $t1 = new Test1(); $t1['huba'] = array('one','two'); $t1['huba'][] = 'three'; print_r($t1); $t2 = new Test2(); $t2['huba'] = array('one','two'); $t2['huba'][] = 'three'; print_r($t2);
Output for 5.3.0 - 7.1.0
Test1 Object ( [storage:ArrayObject:private] => Array ( [huba] => Array ( [0] => one [1] => two [2] => three ) ) ) Notice: Indirect modification of overloaded element of Test2 has no effect in /in/pE9WP on line 17 Test2 Object ( [storage:ArrayObject:private] => Array ( [huba] => Array ( [0] => one [1] => two ) ) )
Output for 5.2.1 - 5.2.17
Test1 Object ( [huba] => Array ( [0] => one [1] => two [2] => three ) ) Notice: Indirect modification of overloaded element of Test2 has no effect in /in/pE9WP on line 17 Test2 Object ( [huba] => Array ( [0] => one [1] => two ) )
Output for 5.2.0
Test1 Object ( [huba] => Array ( [0] => one [1] => two [2] => three ) ) Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in /in/pE9WP on line 17
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in /in/pE9WP on line 12
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Class test1: Cannot inherit from undefined class arrayobject in /in/pE9WP on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Class test1: Cannot inherit from undefined class arrayobject in /in/pE9WP on line 2