3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); /** * @return int|null */ function divide(int $dividend, int $divisor): ?int { if (0 === $divisor) { return null; } return intdiv($dividend, $divisor); } function success(int $result): string { return sprintf('Result: %d', $result); } $result = divide(10, 0); echo success($result);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught TypeError: success(): Argument #1 ($result) must be of type int, null given, called in /in/40vTj on line 23 and defined in /in/40vTj:17 Stack trace: #0 /in/40vTj(23): success(NULL) #1 {main} thrown in /in/40vTj on line 17
Process exited with code 255.

preferences:
72.78 ms | 402 KiB | 62 Q