3v4l.org

run code in 300+ PHP versions simultaneously
<?php # Typed Properties 2.0 # OLD WAY (PHP < 7.4 ) class User { public $id; public $name; public function __construct(int $id, string $name) { $this->id = $id; $this->name = $name; } } $user = new User(10, []); // This Will throw a Fatal error. # Typed Properties with PHP 7.4 All types are supported, with the exception of void and callable. class NewUser { public int $id; public string $name; } $newUser = new NewUser; $newUser->id = 10; $newUser->name = []; // This Will throw a Fatal error too !!
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
Fatal error: Uncaught TypeError: User::__construct(): Argument #2 ($name) must be of type string, array given, called in /in/iFsCM on line 15 and defined in /in/iFsCM:9 Stack trace: #0 /in/iFsCM(15): User->__construct(10, Array) #1 {main} thrown in /in/iFsCM on line 9
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 2 passed to User::__construct() must be of the type string, array given, called in /in/iFsCM on line 15 and defined in /in/iFsCM:9 Stack trace: #0 /in/iFsCM(15): User->__construct(10, Array) #1 {main} thrown in /in/iFsCM on line 9
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Parse error: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/iFsCM on line 19
Process exited with code 255.

preferences:
141.77 ms | 409 KiB | 5 Q