PHP parse int wrong in XAMPP windows

370 views Asked by At

demo

$code = '40001042901';
echo (int)$code; //intval($code) //same

I test on linux (Ubuntu) that result is 40001042901 but on windows result is 2147483647, what wrong with that?

XAMPP 1.8.3, PHP 5.5.15, Apache 2.4.10 (Win32)

1

There are 1 answers

1
AudioBubble On BEST ANSWER

Your Linux result is produced using 64-bit software. The Windows result comes from 32-bit software. The difference here is the maximum size of an integer, which in a 32-bit system is 2147483647.

When you try to parse the string to an integer the value is too large for a 32-bit value so PHP uses the largest available value.

In a 64-bit system integers can be much larger so PHP can use the actual value parsed from your string