How to find out if a shared hosting is running 32 or 64 bit - with php

余生颓废 提交于 2019-12-20 10:34:52

问题


Is it possible to identify Linux 32 or 64 bit, using PHP?

phpinfo() 

returns

Linux infong 2.4 #1 SMP Mon Oct 10 09:34:36 UTC 2011 i686 GNU/Linux 

It's shared hosting so I cant use command line.


回答1:


Do a simple test:

var_dump(is_int( 9223372036854775807 ));

For 32-bit environment it will return false as this number is much bigger that maximum 32-bit integer. For 64-bit environment it will return true.


Or use PHP_INT_MAX as mario suggested in comments.

echo (PHP_INT_MAX == 2147483647)?'32-bit':'64-bit';

Or use PHP_INT_SIZE:

echo (PHP_INT_SIZE * 8) . '-bit';


来源:https://stackoverflow.com/questions/8891304/how-to-find-out-if-a-shared-hosting-is-running-32-or-64-bit-with-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!