编程

PHP 8.4: phpinfo: 显示 PHP 整型大小信息

92 2023-10-22 15:22:00

PHP 8.4 这种 phpinfo() 输出会显示当前 PHP 安装所支持的整型位数(bit)大小。

整型大小也包含在 PHP CLI 输出中:

  Zend Extension => 420230901
  Zend Extension Build => API420230901,TS,VS16
  PHP Extension Build => API20230901,TS,VS16
+ PHP Integer Size => 64 bits

向后兼容性影响

 phpinfo() 中新增的 PHP Integer Size 字段只是一个指示值。PHP 8.4 以及所有此前的版本(PHP ≥ 5.0.5) 都支持以下常量来获取整型大小以及所支持的整型的范围。

The new PHP Integer Size field in phpinfo() output is only an indicative value. PHP 8.4 and all previous versions (since PHP 5.0.5) support the following PHP constants to determine the integer size and the range of supported integers.

  • PHP_INT_SIZE: 整型的字节大小。比如, 64 bits 相当于 PHP_INT_SIZE =8 。T
  • PHP_INT_MIN: 支持的最小整型值; 32 位系统中为 -2147483648,64 位系统中为 -9223372036854775808
  • PHP_INT_MAX: 支持的最大整型值; 32 位系统中为 2147483647, 64 位系统中为 9223372036854775807


 

PHP