如何找出共享主机运行的是32位还是64位-使用PHP [英] How to find out if a shared hosting is running 32 or 64 bit - with php
本文介绍了如何找出共享主机运行的是32位还是64位-使用PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用PHP识别Linux 32位或64位?
Is it possible to identify Linux 32 or 64 bit, using PHP?
phpinfo()
返回
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.
推荐答案
做一个简单的测试:
var_dump(is_int( 9223372036854775807 ));
对于32位环境,它将返回false,因为此数字比最大32位整数大得多.对于64位环境,它将返回true.
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.
或使用PHP_INT_MAX作为注释中建议的马里奥.
Or use PHP_INT_MAX as mario suggested in comments.
echo (PHP_INT_MAX == 2147483647)?'32-bit':'64-bit';
或使用PHP_INT_SIZE:
Or use PHP_INT_SIZE:
echo (PHP_INT_SIZE * 8) . '-bit';
这篇关于如何找出共享主机运行的是32位还是64位-使用PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文