3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyStuff extends ArrayObject { function offsetGet($offset) { echo "Called", PHP_EOL; return parent::offsetGet($offset); } } $array = array( 'foo' => 42, 'baz' => null, ); $array_object = new MyStuff($array); // existing key, non-null value: var_dump(isset($array['foo'])); //true var_dump(empty($array['foo'])); //false var_dump(isset($array_object['foo'])); //true var_dump(empty($array_object['foo'])); //false echo PHP_EOL; // non-existing key: var_dump(isset($array['bar'])); //false var_dump(empty($array['bar'])); //true var_dump(isset($array_object['bar'])); //false var_dump(empty($array_object['bar'])); //true echo PHP_EOL; // key where value is null: var_dump(isset($array['baz'])); //false var_dump(empty($array['baz'])); //true var_dump(isset($array_object['baz'])); //false var_dump(empty($array_object['baz'])); //true
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of MyStuff::offsetGet($offset) should either be compatible with ArrayObject::offsetGet(mixed $key): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XrYKN on line 4 bool(true) bool(false) bool(true) Called bool(false) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(false) Called bool(true)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
70.8 ms | 402 KiB | 8 Q