Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

php

cpu

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.

like image 680
Narek Avatar asked Jan 17 '12 07:01

Narek


People also ask

How can I tell if PHP is 32 or 64 bit?

5) HOW TO CHECK FOR 32 OR 64 BITS PHP To check if you are running on 64-bit, just look under “Architecture” in phpinfo() – X86 is 32-bit, and X64 is 64-bit. Otherwise, if you want to test it out programmatically, you can check the PHP_INT_SIZE constant. It should be 4 for 32-bit, and 8 for 64-bit.

How can I tell if my Linux server is 32 or 64 bit?

Find out if your Linux installation is 32 bit or 64 bitThere is a program called uname installed on Linux that can show us if the Linux system is 32 or 64 bit. If it says x86_64, you are using a 64 bit installation. If it says i368, you are using a 32 bit installation. Uname -i gives you the hardware-platform.

How do I know my server bit?

getconf LONG_BIT command: This command check if the OS (kernel) is 32 bit or 64 bit. uname command: This command prints system information including kernel version and whether kernel (os) is 32 bit or 64 bit. /proc/cpuinfo file: Use this file to determine if CPU is 64 bit or 32 bit i.e. find out CPU architecture.

Is XAMPP 32 or 64 bit?

If you're running windows, XAMPP is running a 32bit version of php, no matter of the installer's architecture.


1 Answers

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';
like image 89
Konrad Dzwinel Avatar answered Oct 21 '22 04:10

Konrad Dzwinel