Does anyone know of a way of checking within PHP if the script is running as either 32-bit or 64-bit? Currently I'm using PHP 5.3.5.
Ideally I'd like to write a function so my code can look like this:
if( is_32bit() === true ) { do_32bit_workaround(); } do_everything_else();
Anyone have any thoughts?
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.
Check PHP Version by Running PHP Code The simplest method to determine the PHP version running on your website is executing a PHP file that contains the following code: <?php echo 'PHP version: '. phpversion (); Create the file using a text editor like gedit or Notepad, and upload it to your website’s document root directory.
This version is not necessarily the one that runs on the hosted websites. On Windows, the PHP path is sometimes not recognized by the system, so the php -v command outputs the ‘ php is not recognized ’ error. To solve this problem, set the PATH environment variable first.
Do we really need these tools to check our PHP code? My experience showed me that software entropy is a real thing. More you will modify your application, more the application has chances to break. Your application will inevitably become more complex. These PHP code quality tools can definitely help you in that matter.
Check the PHP_INT_SIZE
constant. It'll vary based on the size of the register (i.e. 32-bit vs 64-bit).
In 32-bit systems PHP_INT_SIZE
should be 4, for 64-bit it should be 8.
See http://php.net/manual/language.types.integer.php for more details.
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