I have some legacy code on a Windows machine running PHP 5.6 that we will be dismissing but I need to do some migrations from.
I have trivial bit of code that is quite mistifying to me. I've simplified it for this question, but the behavior is the same.
$a = "3109584483";
$b = (int) $a;
var_dump($a);
var_dump($b);
And this is the output:
string(10) "3109584483"
int(2147483647)
I have looked at all the similar questions about this, but they all mention
- Casting a float (not my case)
- Getting the result in a non-10 base (I tried converting
2147483647
from and to common bases like HEX, OCT and BIN, but I can't seem to find a match that would justify the result)
What is the reason of this wrong casting? Thanks in advance for your help!