3v4l.org

run code in 300+ PHP versions simultaneously
<?php spl_autoload_register(function($class) { if ($class === 'A') { class A { public function foo($x): B { return new B; } } } else if ($class === 'B') { class B extends A { public function foo($x): C { return new C; } } } else if ($class === 'C') { class C extends B implements N { } } }); new B;
Output for 8.5.0 - 8.5.3
Fatal error: During inheritance of B, while autoloading C: Uncaught Error: Interface "N" not found in /in/jMYYP:17 Stack trace: #0 /in/jMYYP(11): {closure:/in/jMYYP:3}('C') #1 /in/jMYYP(22): {closure:/in/jMYYP:3}('B') #2 {main} in /in/jMYYP on line 11 Stack trace: #0 /in/jMYYP(22): {closure:/in/jMYYP:3}('B') #1 {main}
Process exited with code 255.
Output for 8.4.1 - 8.4.14, 8.4.16 - 8.4.18
Fatal error: During inheritance of B, while autoloading C: Uncaught Error: Interface "N" not found in /in/jMYYP:17 Stack trace: #0 /in/jMYYP(11): {closure:/in/jMYYP:3}('C') #1 /in/jMYYP(22): {closure:/in/jMYYP:3}('B') #2 {main} in /in/jMYYP on line 11
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.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
Fatal error: During inheritance of B, while autoloading C: Uncaught Error: Interface "N" not found in /in/jMYYP:17 Stack trace: #0 /in/jMYYP(11): {closure}('C') #1 /in/jMYYP(22): {closure}('B') #2 {main} in /in/jMYYP on line 11
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Warning: Uncaught Error: Interface "N" not found in /in/jMYYP:17 Stack trace: #0 /in/jMYYP(11): {closure}('C') #1 /in/jMYYP(22): {closure}('B') #2 {main} thrown in /in/jMYYP on line 17 Fatal error: Could not check compatibility between B::foo($x): C and A::foo($x): B, because class C is not available in /in/jMYYP on line 12
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Uncaught Error: Interface 'N' not found in /in/jMYYP:17 Stack trace: #0 [internal function]: {closure}('C') #1 /in/jMYYP(11): spl_autoload_call('C') #2 [internal function]: {closure}('B') #3 /in/jMYYP(22): spl_autoload_call('B') #4 {main} thrown in /in/jMYYP on line 17 Fatal error: Could not check compatibility between B::foo($x): C and A::foo($x): B, because class C is not available in /in/jMYYP on line 12
Process exited with code 255.
Output for 7.3.0 - 7.3.33
Warning: Uncaught Error: Class 'B' not found in /in/jMYYP:17 Stack trace: #0 [internal function]: {closure}('C') #1 /in/jMYYP(11): spl_autoload_call('C') #2 [internal function]: {closure}('B') #3 /in/jMYYP(22): spl_autoload_call('B') #4 {main} Next Error: Class 'B' not found in /in/jMYYP:17 Stack trace: #0 [internal function]: {closure}('C') #1 /in/jMYYP(11): spl_autoload_call('C') #2 [internal function]: {closure}('B') #3 /in/jMYYP(22): spl_autoload_call('B') #4 {main} thrown in /in/jMYYP on line 17 Fatal error: Declaration of B::foo($x): C must be compatible with A::foo($x): B in /in/jMYYP on line 11
Process exited with code 255.
Output for 7.1.25 - 7.1.31, 7.2.0 - 7.2.33
Fatal error: Class 'B' not found in /in/jMYYP on line 17
Process exited with code 255.

preferences:
93.69 ms | 1499 KiB | 4 Q