3v4l.org

run code in 300+ PHP versions simultaneously
<?php $reflectionMethod = new ReflectionMethod(Exception::class, "__construct"); foreach ($reflectionMethod->getParameters() as $reflectionParameter) { $defaultValue = null; if ($reflectionParameter->isDefaultValueAvailable()) { $defaultValue = $reflectionParameter->getDefaultValue(); $defaultValue = var_export($defaultValue, true); } else if ($reflectionParameter->isDefaultValueConstant()) { $defaultValue = $reflectionParameter->getDefaultValueConstantName(); } if (isset($defaultValue)) { print "Default value of \$" . $reflectionParameter->name . " = " . $defaultValue; } else { print "Default value of \$" . $reflectionParameter->name . " does not exist."; } print PHP_EOL; }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Default value of $message = '' Default value of $code = 0 Default value of $previous = NULL
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught ReflectionException: Cannot determine default value for internal functions in /in/PvAHe:11 Stack trace: #0 /in/PvAHe(11): ReflectionParameter->isDefaultValueConstant() #1 {main} thrown in /in/PvAHe on line 11
Process exited with code 255.
Output for 5.6.0 - 5.6.25
Fatal error: Uncaught exception 'ReflectionException' with message 'Cannot determine default value for internal functions' in /in/PvAHe:11 Stack trace: #0 /in/PvAHe(11): ReflectionParameter->isDefaultValueConstant() #1 {main} thrown in /in/PvAHe on line 11
Process exited with code 255.

preferences:
95.6 ms | 1533 KiB | 4 Q