3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo extends Exception { protected $code = 100; protected $message = 'Hello'; protected int $line = 45; protected string $file = '/path/to/file.php'; } try { throw new Foo(); } catch (Foo $e) { var_dump($e); }
Output for 7.4.0 - 7.4.23, 8.0.0 - 8.0.9
Fatal error: Type of Foo::$file must not be defined (as in class Exception) in /in/UX1Pa on line 9
Process exited with code 255.
Output for 7.3.0 - 7.3.30
Parse error: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/UX1Pa on line 7
Process exited with code 255.

preferences:
188.62 ms | 1386 KiB | 70 Q