3v4l.org

run code in 500+ PHP versions simultaneously
<?php function &test(): int { $x = 0; try { return $x; } finally { $x = 'test'; } } $x = &test(); var_dump($x);
Output for 8.2.0 - 8.2.34, 8.3.0 - 8.3.24, 8.4.1 - 8.4.11
string(4) "test"
Output for 8.3.25 - 8.3.35, 8.4.12 - 8.4.26, 8.5.0 - 8.5.11
Fatal error: Uncaught TypeError: test(): Return value must be of type int, string returned in /in/BRBW9:6 Stack trace: #0 /in/BRBW9(12): test() #1 {main} thrown in /in/BRBW9 on line 6
Process exited with code 255.

preferences:
32.76 ms | 1147 KiB | 13 Q