3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function bar ( int $a, int $b, int $c, int|string $d = 'IV' ) { echo $a . "\n"; echo $b . "\n"; echo $c . "\n"; echo $d . "\n"; } public function baz ( int|string $dd = 'IV', int $aa, int $bb, int $cc, ) { echo $aa . "\n"; echo $bb . "\n"; echo $cc . "\n"; echo $dd . "\n"; } } $Obj = new Foo(); $Obj->bar( c: 3, a: 1, b: 2 ); $Obj->baz( cc: 3, aa: 1, bb: 2 );
Output for 8.4.1 - 8.4.12
Deprecated: Foo::baz(): Optional parameter $dd declared before required parameter $cc is implicitly treated as a required parameter in /in/NToiL on line 16 1 2 3 IV Fatal error: Uncaught ArgumentCountError: Foo::baz(): Argument #1 ($dd) not passed in /in/NToiL:16 Stack trace: #0 /in/NToiL(38): Foo->baz(NULL, 1, 2, 3) #1 {main} thrown in /in/NToiL on line 16
Process exited with code 255.
Output for 8.1.27 - 8.1.33, 8.2.14 - 8.2.29, 8.3.1 - 8.3.25
Deprecated: Optional parameter $dd declared before required parameter $cc is implicitly treated as a required parameter in /in/NToiL on line 16 1 2 3 IV Fatal error: Uncaught ArgumentCountError: Foo::baz(): Argument #1 ($dd) not passed in /in/NToiL:16 Stack trace: #0 /in/NToiL(38): Foo->baz(NULL, 1, 2, 3) #1 {main} thrown in /in/NToiL on line 16
Process exited with code 255.

preferences:
45.37 ms | 408 KiB | 5 Q