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, '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 // non-existing key: var_dump(isset($array['bar'])); //false var_dump(empty($array['bar'])); //true var_dump(isset($array_object['bar'])); //true var_dump(empty($array_object['bar'])); //false // key where value is null: var_dump(isset($array['baz'])); //false var_dump(empty($array['baz'])); //true var_dump(isset($array_object['baz'])); //true var_dump(empty($array_object['baz'])); //false
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/rU77c on line 4 bool(true) bool(false) bool(true) Calledbool(false) bool(false) bool(true) bool(false) bool(true) bool(false) bool(true) bool(false) Calledbool(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:
42.34 ms | 402 KiB | 8 Q