如何使用 php 查明共享主机运行的是 32 位还是 64 位

发布于 2024-12-27 04:43:41 字数 208 浏览 1 评论 0原文

是否可以使用 PHP 识别 Linux 32 位或 64 位?

phpinfo() 

返回

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

它是共享托管,因此我无法使用命令行。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缘字诀 2025-01-03 04:43:41

做一个简单的测试:

var_dump(is_int( 9223372036854775807 ));

对于 32 位环境,它将返回 false,因为该数字比最大 32 位整数大得多。对于 64 位环境它将返回 true。


或者按照 mario 在评论中建议的方式使用 PHP_INT_MAX 。

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

或者使用 PHP_INT_SIZE:

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

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';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文