Compatibility of PHP built-in functions with 32-bit and 64-bit platforms. In the LieHuo. Net tutorial, the integer in PHP is the long type in the C language and is signed. The maximum value is 2 ^ 31. On a 64-bit platform, the length can reach 2 ^ 63. in this case, the integer in PHP in some tutorials (www.Bkjia.com) is the long type in the C language and is signed. The maximum value is 2 ^ 31. On a 64-bit platform, the length can reach 2 ^ 63.
In this way, the output results of some PHP functions will be inconsistent on various platforms.
Php-r "echo ip2long ('192. 00000000255 ');" for 64-bit platforms: 255, for 32-bit platforms:-1. For example, when the file size is larger than 2 GB, the results are inconsistent on different platforms.
To solve this problem, sprintf ("% u", filesize ($ file) converts the result to a string. Why is the result the same? the completion code of the unsigned number 4294967295 is the same as that of the signed number-1. Similarly, functions whose return value is int and whose final result may be greater than 2 ^ 31 must be processed in this way.
Note: Although the returned result is a string, PHP will automatically replace it when performing the four arithmetic operations. If the number is greater than 2 ^ 31, it is converted to int. if the number is greater than 2 ^ 31, it is converted to double.
In the LieHuo. Net tutorial, the integer in PHP is the long type in the C language and is signed. The maximum value is 2 ^ 31. On a 64-bit platform, long can reach 2 ^ 63. in this case, some...