3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyStuff extends ArrayObject { function offsetGet($offset) { echo "Called"; return parent::offsetGet($offset); } } $array = array('foo' => 42); $array_object = new MyStuff($array); var_dump(isset($array['foo'])); //true var_dump(empty($array['foo'])); //false var_dump(isset($array_object['foo'])); //should be true (offsetGet not called) var_dump(empty($array_object['foo'])); //should be false (offsetGet called)

preferences:
39.02 ms | 402 KiB | 5 Q