3v4l.org

run code in 300+ PHP versions simultaneously
<?php function f(string $p1 = 'foo', $p2){ } function test(string $name) { echo new ReflectionFunction($name), "\n"; } echo "--- Test with f() ---\n"; test("f");
Output for 8.4.1 - 8.4.14
Deprecated: f(): Optional parameter $p1 declared before required parameter $p2 is implicitly treated as a required parameter in /in/CCXWB on line 3 --- Test with f() --- Function [ <user> function f ] { @@ /in/CCXWB 3 - 4 - Parameters [2] { Parameter #0 [ <required> string $p1 ] Parameter #1 [ <required> $p2 ] } }
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27
Deprecated: Optional parameter $p1 declared before required parameter $p2 is implicitly treated as a required parameter in /in/CCXWB on line 3 --- Test with f() --- Function [ <user> function f ] { @@ /in/CCXWB 3 - 4 - Parameters [2] { Parameter #0 [ <required> string $p1 ] Parameter #1 [ <required> $p2 ] } }
Output for 8.0.1 - 8.0.30
Deprecated: Required parameter $p2 follows optional parameter $p1 in /in/CCXWB on line 3 --- Test with f() --- Function [ <user> function f ] { @@ /in/CCXWB 3 - 4 - Parameters [2] { Parameter #0 [ <required> string $p1 ] Parameter #1 [ <required> $p2 ] } }

preferences:
98.75 ms | 409 KiB | 5 Q