检查您的代码是否在64位PHP上运行 [英] Checking if your code is running on 64-bit PHP
本文介绍了检查您的代码是否在64位PHP上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道一种在PHP中检查脚本是32位还是64位运行的方法吗?目前,我正在使用PHP 5.3.5.
Does anyone know of a way of checking within PHP if the script is running as either 32-bit or 64-bit? Currently I'm using PHP 5.3.5.
理想情况下,我想编写一个函数,以便我的代码看起来像这样:
Ideally I'd like to write a function so my code can look like this:
if( is_32bit() === true ) {
do_32bit_workaround();
}
do_everything_else();
有人有什么想法吗?
推荐答案
检查PHP_INT_SIZE
常量.它会根据寄存器的大小(即32位和64位)而有所不同.
Check the PHP_INT_SIZE
constant. It'll vary based on the size of the register (i.e. 32-bit vs 64-bit).
在32位系统中,PHP_INT_SIZE
应为 4 ,对于64位系统,应为 8 .
In 32-bit systems PHP_INT_SIZE
should be 4, for 64-bit it should be 8.
请参见 http://php.net/manual/language.types.integer. php 了解更多详细信息.
See http://php.net/manual/language.types.integer.php for more details.
这篇关于检查您的代码是否在64位PHP上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文