3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class Foo implements Stringable { public function __toString() { return "Foo"; } } function greet(string $s) { echo "Hello $s"; } greet(new Foo());
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.14
Fatal error: Uncaught TypeError: greet(): Argument #1 ($s) must be of type string, Foo given, called in /in/MWhHC on line 15 and defined in /in/MWhHC:11 Stack trace: #0 /in/MWhHC(15): greet(Object(Foo)) #1 {main} thrown in /in/MWhHC on line 11
Process exited with code 255.

preferences:
55.82 ms | 406 KiB | 5 Q