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.
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.
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.
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.
If you're running windows, XAMPP is running a 32bit version of php, no matter of the installer's architecture.
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';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With