3v4l.org

run code in 500+ PHP versions simultaneously
<?php class base implements ArrayAccess { public function offsetSet($propertyName, $value) { $this->$propertyName = $value; } public function offsetExists($propertyName) { return isset($this->$propertyName); } public function offsetUnset($propertyName) { unset($this->$propertyName); } public function offsetGet($propertyName) { return isset($this->$propertyName) ? $this->$propertyName : null; } } class User extends base { public $foreName; public $familyName; public function __construct($forename, $familyname) { $this->foreName = $forename; $this->familyName = $familyname; } } $data = new User('Mark', 'Baker'); echo $data['foreName'], PHP_EOL; $data['foreName'] = 'SuperMark'; echo $data['foreName'], PHP_EOL;
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.6
Deprecated: Return type of base::offsetExists($propertyName) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/MajRB on line 8 Deprecated: Return type of base::offsetGet($propertyName) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/MajRB on line 16 Deprecated: Return type of base::offsetSet($propertyName, $value) 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/MajRB on line 4 Deprecated: Return type of base::offsetUnset($propertyName) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/MajRB on line 12 Mark SuperMark
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 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
Mark SuperMark

preferences:
97.69 ms | 2090 KiB | 4 Q