3v4l.org

run code in 500+ PHP versions simultaneously
<?php function absint_dennis( $maybeint ) { return min( PHP_INT_MAX, abs( (int) $maybeint ) ); } $values = array( PHP_INT_MIN, PHP_INT_MIN * 2, PHP_INT_MAX, PHP_INT_MAX * 2, ); foreach ( $values as $value ) { echo "absint( $value ) === "; var_dump( absint_dennis( $value ) ); echo "\n\n"; }
Output for 8.5.9
absint( -9223372036854775808 ) === float(9.223372036854776E+18) absint( -1.844674407371E+19 ) === Warning: The float -1.8446744073709552E+19 is not representable as an int, cast occurred in /in/VMXR3 on line 4 int(0) absint( 9223372036854775807 ) === int(9223372036854775807) absint( 1.844674407371E+19 ) === Warning: The float 1.8446744073709552E+19 is not representable as an int, cast occurred in /in/VMXR3 on line 4 int(0)

preferences:
56.49 ms | 481 KiB | 4 Q