3v4l.org

run code in 300+ PHP versions simultaneously
<?php function a($val) { $maxValue = (int) (\PHP_INT_MAX / 1000); $value = $val * 1000; echo 'Value: '.\gettype($val).' '.$val.PHP_EOL; echo 'Timer: '.\gettype($value).' '.$value.PHP_EOL; echo 'Casted: '.((int) $value).PHP_EOL; echo 'Overflow: '.\var_export($val > $maxValue, true).PHP_EOL; echo 'Overflow <0: '.\var_export(((int) $value) <= 0 && $val > 0, true).PHP_EOL; echo 'PHP Overflow: '.\var_export($value > \PHP_INT_MAX, true).PHP_EOL; echo 'Overflow combined: '.\var_export($value > \PHP_INT_MAX || (((int) $value) <= 0 && $val > 0), true).PHP_EOL; echo 'Supposed to fail: '.\var_export(\gettype($value) === 'double', true).PHP_EOL; echo PHP_EOL; } $maxValue = (int) (\PHP_INT_MAX / 1000); echo 'Max value: '.$maxValue.PHP_EOL; echo 'Max PHP value: '.\PHP_INT_MAX.PHP_EOL.PHP_EOL; a($maxValue); a($maxValue - 1); a($maxValue + 1); a($maxValue + 10); a($maxValue + 10000000); a(\PHP_INT_MAX); a(\PHP_INT_MAX + 1); a(\PHP_INT_MAX + 10); a(\PHP_INT_MAX + 100); a(\PHP_INT_MAX + 10000000); a(\PHP_INT_MAX * 1000);
Output for 8.5.0 - 8.5.1
Max value: 9223372036854776 Max PHP value: 9223372036854775807 Value: integer 9223372036854776 Timer: double 9.2233720368548E+18 Warning: The float 9.223372036854776E+18 is not representable as an int, cast occurred in /in/TIkG3 on line 9 Casted: -9223372036854775808 Overflow: false Warning: The float 9.223372036854776E+18 is not representable as an int, cast occurred in /in/TIkG3 on line 11 Overflow <0: true PHP Overflow: false Warning: The float 9.223372036854776E+18 is not representable as an int, cast occurred in /in/TIkG3 on line 13 Overflow combined: true Supposed to fail: true Value: integer 9223372036854775 Timer: integer 9223372036854775000 Casted: 9223372036854775000 Overflow: false Overflow <0: false PHP Overflow: false Overflow combined: false Supposed to fail: false Value: integer 9223372036854777 Timer: double 9.2233720368548E+18 Warning: The float 9.223372036854776E+18 is not representable as an int, cast occurred in /in/TIkG3 on line 9 Casted: -9223372036854775808 Overflow: true Warning: The float 9.223372036854776E+18 is not representable as an int, cast occurred in /in/TIkG3 on line 11 Overflow <0: true PHP Overflow: false Warning: The float 9.223372036854776E+18 is not representable as an int, cast occurred in /in/TIkG3 on line 13 Overflow combined: true Supposed to fail: true Value: integer 9223372036854786 Timer: double 9.2233720368548E+18 Warning: The float 9.223372036854786E+18 is not representable as an int, cast occurred in /in/TIkG3 on line 9 Casted: -9223372036854765568 Overflow: true Warning: The float 9.223372036854786E+18 is not representable as an int, cast occurred in /in/TIkG3 on line 11 Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: integer 9223372046854776 Timer: double 9.2233720468548E+18 Warning: The float 9.223372046854777E+18 is not representable as an int, cast occurred in /in/TIkG3 on line 9 Casted: -9223372026854774784 Overflow: true Warning: The float 9.223372046854777E+18 is not representable as an int, cast occurred in /in/TIkG3 on line 11 Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: integer 9223372036854775807 Timer: double 9.2233720368548E+21 Warning: The float 9.223372036854776E+21 is not representable as an int, cast occurred in /in/TIkG3 on line 9 Casted: 0 Overflow: true Warning: The float 9.223372036854776E+21 is not representable as an int, cast occurred in /in/TIkG3 on line 11 Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: double 9.2233720368548E+18 Timer: double 9.2233720368548E+21 Warning: The float 9.223372036854776E+21 is not representable as an int, cast occurred in /in/TIkG3 on line 9 Casted: 0 Overflow: true Warning: The float 9.223372036854776E+21 is not representable as an int, cast occurred in /in/TIkG3 on line 11 Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: double 9.2233720368548E+18 Timer: double 9.2233720368548E+21 Warning: The float 9.223372036854776E+21 is not representable as an int, cast occurred in /in/TIkG3 on line 9 Casted: 0 Overflow: true Warning: The float 9.223372036854776E+21 is not representable as an int, cast occurred in /in/TIkG3 on line 11 Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: double 9.2233720368548E+18 Timer: double 9.2233720368548E+21 Warning: The float 9.223372036854776E+21 is not representable as an int, cast occurred in /in/TIkG3 on line 9 Casted: 0 Overflow: true Warning: The float 9.223372036854776E+21 is not representable as an int, cast occurred in /in/TIkG3 on line 11 Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: double 9.2233720368648E+18 Timer: double 9.2233720368648E+21 Warning: The float 9.223372036864776E+21 is not representable as an int, cast occurred in /in/TIkG3 on line 9 Casted: 10000269312 Overflow: true Warning: The float 9.223372036864776E+21 is not representable as an int, cast occurred in /in/TIkG3 on line 11 Overflow <0: false PHP Overflow: true Overflow combined: true Supposed to fail: true Value: double 9.2233720368548E+21 Timer: double 9.2233720368548E+24 Warning: The float 9.223372036854776E+24 is not representable as an int, cast occurred in /in/TIkG3 on line 9 Casted: 0 Overflow: true Warning: The float 9.223372036854776E+24 is not representable as an int, cast occurred in /in/TIkG3 on line 11 Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true
Output for 7.1.25 - 7.1.30, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.4.16
Max value: 9223372036854776 Max PHP value: 9223372036854775807 Value: integer 9223372036854776 Timer: double 9.2233720368548E+18 Casted: -9223372036854775808 Overflow: false Overflow <0: true PHP Overflow: false Overflow combined: true Supposed to fail: true Value: integer 9223372036854775 Timer: integer 9223372036854775000 Casted: 9223372036854775000 Overflow: false Overflow <0: false PHP Overflow: false Overflow combined: false Supposed to fail: false Value: integer 9223372036854777 Timer: double 9.2233720368548E+18 Casted: -9223372036854775808 Overflow: true Overflow <0: true PHP Overflow: false Overflow combined: true Supposed to fail: true Value: integer 9223372036854786 Timer: double 9.2233720368548E+18 Casted: -9223372036854765568 Overflow: true Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: integer 9223372046854776 Timer: double 9.2233720468548E+18 Casted: -9223372026854774784 Overflow: true Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: integer 9223372036854775807 Timer: double 9.2233720368548E+21 Casted: 0 Overflow: true Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: double 9.2233720368548E+18 Timer: double 9.2233720368548E+21 Casted: 0 Overflow: true Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: double 9.2233720368548E+18 Timer: double 9.2233720368548E+21 Casted: 0 Overflow: true Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: double 9.2233720368548E+18 Timer: double 9.2233720368548E+21 Casted: 0 Overflow: true Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true Value: double 9.2233720368648E+18 Timer: double 9.2233720368648E+21 Casted: 10000269312 Overflow: true Overflow <0: false PHP Overflow: true Overflow combined: true Supposed to fail: true Value: double 9.2233720368548E+21 Timer: double 9.2233720368548E+24 Casted: 0 Overflow: true Overflow <0: true PHP Overflow: true Overflow combined: true Supposed to fail: true
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
221.25 ms | 419 KiB | 5 Q