3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo(\DateTime $d) { print __LINE__ . PHP_EOL; } foo('5');
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught TypeError: foo(): Argument #1 ($d) must be of type DateTime, string given, called in /in/XL0Of on line 7 and defined in /in/XL0Of:3 Stack trace: #0 /in/XL0Of(7): foo('5') #1 {main} thrown in /in/XL0Of on line 3
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to foo() must be an instance of DateTime, string given, called in /in/XL0Of on line 7 and defined in /in/XL0Of:3 Stack trace: #0 /in/XL0Of(7): foo('5') #1 {main} thrown in /in/XL0Of on line 3
Process exited with code 255.
Output for 5.6.0 - 5.6.24
Catchable fatal error: Argument 1 passed to foo() must be an instance of DateTime, string given, called in /in/XL0Of on line 7 and defined in /in/XL0Of on line 3
Process exited with code 255.

preferences:
234.95 ms | 402 KiB | 230 Q