3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test extends \ArrayObject { public $defaults = array( 'k3' => 'v3', ); public function __construct() { parent::__construct( array( 'k1' => 'v1', 'k2' => 'v2', 'k3' => null, ) ); } public function offsetGet( $index ) { if ( isset( $this[$index] ) ) { return parent::offsetGet( $index ); } elseif ( isset( $this->defaults[ $index ] ) ) { return $this->defaults[ $index ]; } else { return null; } } } $o = new Test(); var_dump( isset( $o['k1'] ) ); var_dump( isset( $o['k3'] ) );
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Test::offsetGet($index) should either be compatible with ArrayObject::offsetGet(mixed $key): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/fnKPG on line 19 bool(true) bool(false)

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.21 ms | 402 KiB | 8 Q