Narek
Narek

Reputation: 3823

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

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.

Upvotes: 13

Views: 4584

Answers (1)

Konrad Dzwinel
Konrad Dzwinel

Reputation: 37903

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';

Upvotes: 23

Related Questions