Skip to content

Instantly share code, notes, and snippets.

@bzikarsky
Created December 29, 2013 22:05
Show Gist options
  • Save bzikarsky/8175406 to your computer and use it in GitHub Desktop.
Save bzikarsky/8175406 to your computer and use it in GitHub Desktop.
Test PHP integer overflow
<?php
echo "var_dump(...)\n";
echo "\n";
echo "PHP_INT_MAX : ";
var_dump(PHP_INT_MAX);
echo "PHP_INT_MAX + 1 : ";
var_dump(PHP_INT_MAX + 1);
echo "PHP_INT_MAX + 1000 : ";
var_dump(PHP_INT_MAX + 1000);
echo "PHP_INT_MAX * 2 + 4: ";
var_dump(PHP_INT_MAX * 2 + 4);
echo "9.2233720368548E+18: ";
var_dump(9.2233720368548E+18);
echo "1.844674407371E+19 : ";
var_dump(1.844674407371E+19);
echo "\n";
echo "var_dump((int) ...)\n";
echo "\n";
echo "PHP_INT_MAX : ";
var_dump((int)(PHP_INT_MAX));
echo "PHP_INT_MAX + 1 : ";
var_dump((int)(PHP_INT_MAX + 1));
echo "PHP_INT_MAX + 1000 : ";
var_dump((int)(PHP_INT_MAX + 1000));
echo "PHP_INT_MAX * 2 + 4: ";
var_dump((int)(PHP_INT_MAX * 2 + 4));
echo "9.2233720368548E+18: ";
var_dump((int)(9.2233720368548E+18));
echo "1.844674407371E+19 : ";
var_dump((int)(1.844674407371E+19));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment