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, 'k' => 0, ); $array_object = new MyStuff($array); // existing key, non-null value: assert(isset($array['foo']) === true); assert(empty($array['foo']) === false); assert(isset($array_object['foo']) === true); assert(empty($array_object['foo']) === false); // non-existing key: assert(isset($array['bar']) === false); assert(empty($array['bar']) === true); assert(isset($array_object['bar']) === false); assert(empty($array_object['bar']) === true); // key where value is null: assert(isset($array['baz']) === false); assert(empty($array['baz']) === true); assert(isset($array_object['baz']) === false); assert(empty($array_object['baz']) === true); // key where value is 0: assert(isset($array['k']) === true); assert(empty($array['k']) === true); assert(isset($array_object['k']) === true); assert(empty($array_object['k']) === 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/M7tps on line 4 Called Called Called

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:
35.59 ms | 401 KiB | 8 Q