PHP built-in functions 32-bit and 64-bit platform compatibility question _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.