3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on JRE77
Output for 7.0.0 - 7.2.0
string(130) "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" string(131) "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 "
Output for 5.3.19 - 5.6.28
Fatal error: Call to undefined function intdiv() in /in/cDHDl on line 5
Process exited with code 255.