3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { public readonly int $uid; public function __construct(int $uid) { $this->uid = $uid; } } $user = new User(42); $user->__construct(43);
Output for 8.1.0 - 8.1.12
Fatal error: Uncaught Error: Cannot modify readonly property User::$uid in /in/kiqPC:7 Stack trace: #0 /in/kiqPC(12): User->__construct(43) #1 {main} thrown in /in/kiqPC on line 7
Process exited with code 255.
Output for 8.0.1 - 8.0.25
Parse error: syntax error, unexpected identifier "int", expecting variable in /in/kiqPC on line 4
Process exited with code 255.
Output for 7.4.0 - 7.4.32
Parse error: syntax error, unexpected 'int' (T_STRING), expecting variable (T_VARIABLE) in /in/kiqPC on line 4
Process exited with code 255.

preferences:
163.72 ms | 1436 KiB | 14 Q