I am using PHP 5.3.
On my 32-bit system the size of an INT:
print "PHP_INT_MAX: " . PHP_INT_MAX . "\n";
print "PHP_INT_SIZE: " . PHP_INT_SIZE . " bytes (" . (PHP_INT_SIZE * 8) . " bits)\n";
- PHP_INT_MAX: 2147483647
- PHP_INT_SIZE: 4 bytes (32 bits)
However, part of an an encoding algorithm I am using relies on the fact that an int is the above size (4 bytes). When I run the code on my web host's server, it is a 64-bit system and the int size is twice as large.
Is there a way to force "(int)" cast to use the 32-bit size?
For example, assume the following code:
$test = 4170266799;
print $test;
print (int) $test;
On my 32-bit system, the output is:
4170266799
-124700497
On my 64-bit system, the output is:
4170266799
4170266799
Is it possible to force the value of an INT to be 4 bytes, even when the architecture changes from 32-bit to 64-bit?