3v4l.org

run code in 300+ PHP versions simultaneously
<?php ob_start(); var_dump(intdiv(3, 2)); var_dump(intdiv(-3, 2)); var_dump(intdiv(3, -2)); var_dump(intdiv(-3, -2)); var_dump(intdiv(PHP_INT_MAX, PHP_INT_MAX)); var_dump(intdiv(~PHP_INT_MAX, ~PHP_INT_MAX)); try { var_dump(intdiv(~PHP_INT_MAX, -1)); } catch (Throwable $e) { echo "Exception: " . $e->getMessage() . "\n"; } try { var_dump(intdiv(1, 0)); } catch (Throwable $e) { echo "Exception: " . $e->getMessage() . "\n"; } $result = ob_get_contents(); ob_end_clean(); $expectedOutput = <<<EOT +int(1) +int(-1) +int(-1) +int(1) +int(1) +int(1) +Exception: Division of PHP_INT_MIN by -1 is not an integer +Exception: Division by zero +EOT; var_dump($expectedOutput); var_dump($result);
Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.30, 5.6.7 - 5.6.14
Parse error: syntax error, unexpected end of file in /in/JRE77 on line 37
Process exited with code 255.

preferences:
194.3 ms | 1399 KiB | 67 Q