3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class Foo { private array $data = []; public function __set(string $name, $value): void { $this->data[$name] = $value; } public function __isset(string $name): bool { return isset($this->data[$name]); } public function __unset(string $name): void { unset($this->data[$name]); } } $foo = new Foo(); $foo->1 = 'one'; $foo->2 = 'two'; var_dump( isset($foo->1), // true isset($foo->2) // true ); unset($foo->1); var_dump( isset($foo->1) // false );
Output for 7.4.0 - 7.4.4
Parse error: syntax error, unexpected '1' (T_LNUMBER), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /in/pPJDt on line 25
Process exited with code 255.
Output for 7.2.0 - 7.2.29, 7.3.0 - 7.3.16
Parse error: syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST) in /in/pPJDt on line 5
Process exited with code 255.

preferences:
179.61 ms | 1395 KiB | 59 Q