3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function foo(int $x, ?int &$y) { var_dump(isset($y)); if ($y != null) { $y = $x ** 2; } return $x * 2; } var_dump([foo(5, $a), $a]); var_dump([foo(3)]);
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
bool(false) array(2) { [0]=> int(10) [1]=> NULL } Fatal error: Uncaught ArgumentCountError: Too few arguments to function foo(), 1 passed in /in/3WkiP on line 14 and exactly 2 expected in /in/3WkiP:5 Stack trace: #0 /in/3WkiP(14): foo(3) #1 {main} thrown in /in/3WkiP on line 5
Process exited with code 255.

preferences:
48.33 ms | 406 KiB | 5 Q