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.5.0
Deprecated: Foo::baz(): Optional parameter $dd declared before required parameter $cc is implicitly treated as a required parameter in /in/NToiL on line 17 1 2 3 IV Fatal error: Uncaught ArgumentCountError: Foo::baz(): Argument #1 ($dd) not passed in /in/NToiL:17 Stack trace: #0 /in/NToiL(38): Foo->baz(NULL, 1, 2, 3) #1 {main} thrown in /in/NToiL on line 17
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.4.1 - 8.4.14
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.28
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:
100.67 ms | 411 KiB | 5 Q