3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function __construct() { if (version_compare(PHP_VERSION, '7.0.0', '<')) { class Throwable extends Exception {}; class ParseError extends Exception {}; echo "Defined\n"; } } } $a = new Test(); var_dump(class_exists('Throwable'));
Output for 8.5.0
Fatal error: Class declarations may not be nested in /in/dsd0C on line 8 Stack trace: #0 {main}
Process exited with code 255.
Output for 8.2.27 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.15
Fatal error: Class declarations may not be nested in /in/dsd0C on line 8
Process exited with code 255.

preferences:
163.15 ms | 1015 KiB | 7 Q