3v4l.org

run code in 300+ PHP versions simultaneously
<?php //! PHP magic wrapper class Magic0 implements ArrayAccess { var $properties; //protected would be better function exists($key) { return isset($this->properties[$key]); } function set($key,$val) { return $this->properties[$key]=$val; } function get($key) { return isset($this->properties[$key])?$this->properties[$key]:NULL; } function clear($key) { unset($this->properties[$key]); } function __isset($key) { return $this->offsetexists($key); } function __set($key,$val) { return $this->offsetset($key,$val); } function offsetexists($key) { return exists($key); } function offsetset($key,$val) { return $this->set($key,$val); } function offsetget($key) { return $this->get($key); } function offsetunset($key) { $this->clear($key); } function __get($key) { return $this->offsetget($key); } function __unset($key) { $this->offsetunset($key); } } //in every case, it will create entry in internal array $sample=new Magic0(); $sample->a=11; $sample->b="Muse"; $sample['c']=13; //we can get them through array index as well echo $sample['a'] ."\n"; echo $sample['b'] ."\n"; echo $sample->c ."\n";
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Magic0::offsetexists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/PCn1n on line 35 Deprecated: Return type of Magic0::offsetget($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/PCn1n on line 43 Deprecated: Return type of Magic0::offsetset($key, $val) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/PCn1n on line 39 Deprecated: Return type of Magic0::offsetunset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/PCn1n on line 48 11 Muse 13

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.74 ms | 403 KiB | 8 Q