3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Data implements \ArrayAccess, \Countable, \IteratorAggregate { /** * * Key-value pairs of data. * * @var array * */ protected $data = array(); /** * * Constructor. * * @param array $data The data for this object. * */ public function __construct(array $data = array()) { $this->data = $data; } /** * * ArrayAccess: does the requested key exist? * * @param int|string $key The requested key. * * @return bool * */ public function offsetExists($key) { return array_key_exists($key, $this->data); } /** * * ArrayAccess: get a key value. * * @param int|string $key The requested key. * * @return mixed * */ public function offsetGet($key) { return $this->data[$key]; } /** * * ArrayAccess: set a key value. * * @param int|string $key The requested key. * * @param mixed $val The value to set it to. * * @return void * */ public function offsetSet($key, $val) { $this->data[$key] = $val; } /** * * ArrayAccess: unset a key. * * @param int|string $key The requested key. * * @return void * */ public function offsetUnset($key) { unset($this->data[$key]); } /** * * Countable: how many keys are there? * * @return int * */ public function count() { return count($this->data); } /** * * IteratorAggregate: returns an external iterator for this struct. * * @return DataIterator * */ public function getIterator() { return new DataIterator($this, array_keys($this->data)); } }
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Deprecated: Return type of Data::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/tJmrT on line 34 Deprecated: Return type of Data::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/tJmrT on line 48 Deprecated: Return type of Data::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/tJmrT on line 64 Deprecated: Return type of Data::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/tJmrT on line 78 Deprecated: Return type of Data::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/tJmrT on line 90 Deprecated: Return type of Data::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/tJmrT on line 102
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tJmrT on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tJmrT on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tJmrT on line 2
Output for 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tJmrT on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tJmrT on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/tJmrT on line 2 Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/tJmrT on line 20
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/tJmrT on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting '{' in /in/tJmrT on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'{'' in /in/tJmrT on line 2
Process exited with code 255.

preferences:
242.03 ms | 401 KiB | 353 Q