3v4l.org

run code in 300+ PHP versions simultaneously
<?php try { function hello_1(?string $whom): ?string { if ($whom !== null) { return "Hello $whom"; } } var_dump(hello_1(null)); } catch (\Error $e) { echo $e->getMessage() . PHP_EOL; } /*try { function hello_2(?string $whom): ?string { if ($whom !== null) { return "Hello $whom"; } return; } var_dump(hello_2(null)); } catch (\Error $e) { echo $e->getMessage() . PHP_EOL; } Fatal error: A function with return type must return a value (did you mean "return null;" instead of "return;"?) in /in/QRj2G on line 20 */ try { function hello_3(?string $whom): ?string { if ($whom !== null) { return "Hello $whom"; } return null; } var_dump(hello_3(null)); } catch (\Error $e) { echo $e->getMessage() . PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
hello_1(): Return value must be of type ?string, none returned NULL

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
131.17 ms | 405 KiB | 5 Q