3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class test implements ArrayAccess { public $v; function __construct() { $this->v = array( 'a' => array('b' => 'c'), 'd' => array('e' => 'f'), 'g' => array('h' => 'i') ); } function offsetExists($offset) { return isset($this->v); } function &offsetGet($offset) { return isset($this->var[$offset]) ? $this->var[$offset] : ($null =null); } function offsetSet($offset, $value) { if (is_null($offset)) { $this->v[] = $value; } else { $this->v[$offset] = $value; } } function offsetUnset($offset) { unset($this->v[$offset]); } } $test = new test(); $test['a']['b'] = 'zzz'; print_r($test->v);
based on cI7g4
Output for 7.1.0 - 7.2.0
Notice: Only variable references should be returned by reference in /in/GPahg on line 23 Array ( [a] => Array ( [b] => c ) [d] => Array ( [e] => f ) [g] => Array ( [h] => i ) )
Output for 5.3.17 - 7.0.20
Notice: Only variable references should be returned by reference in /in/GPahg on line 23 Notice: Indirect modification of overloaded element of test has no effect in /in/GPahg on line 42 Array ( [a] => Array ( [b] => c ) [d] => Array ( [e] => f ) [g] => Array ( [h] => i ) )