3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); namespace App; spl_autoload_register(function (string $name): void { printf("autoload: %s\n", $name); }); use stdClass; use Lib\Bar; final class Foo { public C1 $c1; public function method(C2 $c2) {} } $foo = new Foo(); try { $foo->c1 = new stdClass(); } catch (\Throwable $e) { // TypeError にはなるがオートローダは実行されない var_dump($e->getMessage()); } try { $foo->method(new stdClass()); } catch (\Throwable $e) { // TypeError にはなるがオートローダは実行されない var_dump($e->getMessage()); } var_dump(C3::class); var_dump($foo instanceOf C4);
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.14, 8.4.16 - 8.4.18, 8.5.0 - 8.5.3
string(62) "Cannot assign stdClass to property App\Foo::$c1 of type App\C1" string(107) "App\Foo::method(): Argument #1 ($c2) must be of type App\C2, stdClass given, called in /in/MtoWM on line 28" string(6) "App\C3" bool(false)
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.

preferences:
91.84 ms | 479 KiB | 5 Q