3v4l.org

run code in 300+ PHP versions simultaneously
<?php $base = sys_get_temp_dir() . '/gh10232-base'; if (!is_dir($base)) { mkdir($base) or die; } $files = [ 'gh10232.php' => <<<'END' <?php set_include_path('gh10232-nonexistent') or exit(1); chdir(__DIR__) or exit(1); spl_autoload_register(function () { trigger_error(__LINE__); $ex = new Exception(); echo 'Exception on line ', $ex->getLine(), "\n"; require_once __DIR__ . '/gh10232/constant_def.inc'; }, true); class ConstantRef { public const VALUE = ConstantDef::VALUE; } ConstantRef::VALUE; END, 'gh10232/constant_def.inc' => <<<'END' <?php trigger_error(basename(__FILE__)); $ex = new Exception(); echo 'Exception in ', basename($ex->getFile()), ' on line ', $ex->getLine(), "\n"; require_once 'required.inc'; // The script of the same directory. class ConstantDef { const VALUE = true; } END, 'gh10232/required.inc' => <<<'END' <?php trigger_error(basename(__FILE__)); $ex = new Exception(); echo 'Exception in ', basename($ex->getFile()), ' on line ', $ex->getLine(), "\n"; END, ]; foreach ($files as $path => $content) { $path = $base . '/' . $path; if (!is_dir(dirname($path))) { mkdir(dirname($path)); } file_put_contents($path, $content); } require_once $base . '/' . (function_exists('array_key_first') ? array_key_first($files) : key($files));
Output for 8.1.0 - 8.1.33, 8.2.19 - 8.2.29, 8.3.7 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
Notice: 7 in /tmp/gh10232-base/gh10232.php on line 7 Exception on line 8 Notice: constant_def.inc in /tmp/gh10232-base/gh10232/constant_def.inc on line 3 Exception in constant_def.inc on line 4 Notice: required.inc in /tmp/gh10232-base/gh10232/required.inc on line 3 Exception in required.inc on line 4
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.3.0 - 8.3.6
Notice: 7 in /tmp/gh10232-base/gh10232.php on line 16 Exception on line 16 Notice: constant_def.inc in /tmp/gh10232-base/gh10232.php on line 16 Exception in gh10232.php on line 16 Warning: require_once(required.inc): Failed to open stream: No such file or directory in /tmp/gh10232-base/gh10232.php on line 16 Fatal error: Uncaught Error: Failed opening required 'required.inc' (include_path='gh10232-nonexistent') in /tmp/gh10232-base/gh10232.php:16 Stack trace: #0 /tmp/gh10232-base/gh10232/constant_def.inc(7): [constant expression]() #1 /tmp/gh10232-base/gh10232.php(10): require_once() #2 /tmp/gh10232-base/gh10232.php(19): {closure}('ConstantDef') #3 /in/v4nl0(62): require_once('/tmp/gh10232-ba...') #4 {main} thrown in /tmp/gh10232-base/gh10232.php on line 16
Process exited with code 255.
Output for 8.2.0 - 8.2.18
Notice: 7 in /tmp/gh10232-base/gh10232.php on line 16 Exception on line 16 Notice: constant_def.inc in /tmp/gh10232-base/gh10232.php on line 16 Exception in gh10232.php on line 16 Warning: require_once(required.inc): Failed to open stream: No such file or directory in /tmp/gh10232-base/gh10232.php on line 16 Fatal error: Uncaught Error: Failed opening required 'required.inc' (include_path='gh10232-nonexistent') in /tmp/gh10232-base/gh10232.php:16 Stack trace: #0 /tmp/gh10232-base/gh10232.php(10): require_once() #1 /tmp/gh10232-base/gh10232.php(19): {closure}('ConstantDef') #2 /in/v4nl0(62): require_once('/tmp/gh10232-ba...') #3 {main} thrown in /tmp/gh10232-base/gh10232.php on line 16
Process exited with code 255.

preferences:
97.06 ms | 412 KiB | 5 Q