Find Windows 32 or 64 bit using PHP
<?php
switch(PHP_INT_SIZE) {
case 4:
echo '32-bit version of PHP';
break;
case 8:
echo '64-bit version of PHP';
break;
default:
echo 'PHP_INT_SIZE is ' . PHP_INT_SIZE;
}
This code snippet will at-least tell you if a 32/64 bit version of PHP is running. How can I determine whether my OS is 32 or 64 bit?
My best guess is that even though your OS is 64bit, your Webserver is x86 and runs in WOW64-mode (32bit). If that's the case, it should be hard to figure out in pure PHP.
My suggestion (thanks to Leigh for linking to a similar question) is to use WMI:
$out = array();
exec("wmic cpu get DataWidth", $out);
$bits = strstr(implode("", $out), "64") ? 64 : 32;
echo $bits; // 32 or 64
Can PHP tell if the server os is 64-bit?
Note: This solution is a bit less convenient and slower than @Salman A's answer. I would advice you to use his solution and check for PHP_INT_SIZE == 8
to see if you're on a 64bit os.
If you just want to answer the 32bit/64bit question, a sneaky little function like this would do the trick (taking advantage of the intval function's way of handling ints based on 32/64 bit.)
<?php
function is_64bit()
{
$int = "9223372036854775807";
$int = intval($int);
if ($int == 9223372036854775807) {
/* 64bit */
return true;
} elseif ($int == 2147483647) {
/* 32bit */
return false;
} else {
/* error */
return "error";
}
}
?>
You can see the code in action here: http://ideone.com/JWKIfNote: If the OS is 64bit but running a 32 bit version of php, the function will return false (32 bit)...
Checking if your code is running on 64-bit PHP
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.
Windows PHP 64-bit or 32-bit
php-cgi.exe
is included as standard in the PHP Binaries. You just need to set up a FastCGI handler mapping in IIS once you've downloaded and unzipped the PHP binaries.
How can I see if my XAMPP is running 32 bit or 64 bit?
If you're running windows, XAMPP is running a 32bit version of php, no matter of the installer's architecture.
UPDATE 10/23/2019
It would appear that since the latest build (Sep 24 2019)
Xampp now serves x64 by default and not x32
You can check your version by running php -v and reading the build date & architecture
Using php 7.3.4 64bit with a 64bit oracle client and php 7.3.4 32bit with a 32bit oracle client on the same server
Problem solved.
Everything was correctly, but the oracle setup forgot the correct windows right for the clientx64
folder.
At the clientx86
the group "authenticated user" (in german: Authentifizierter Benutzer) has full access, while the clientx64
doesnt have this group.
After adding the group and give it full access to the clientx64
folder it works. It isn't necessary to switch the entries in the PATH variable. PHP try to loading the first element and after failing it loads the second element in PATH variable.
So everything works!
Related Topics
Howto Generate JSON with Smarty
Laravel - Validate File Size When PHP Max Upload Size Limit Is Exceeded
Uploading Image from Android to PHP Server
Php: Require Path Does Not Work for Cron Job
File_Get_Contents(): Stream Does Not Support Seeking/When Was PHP Behavior About This Changed
PHP Datetime::Createfromformat Doesn't Parse Iso 8601 Date Time
How to Access Magento Customer's Session from Outside Magento
Determining If a File Exists in Laravel 5
Creating and Invoking an Anonymous Function in a Single Statement
How to Force Ssl in Codeigniter
Symfony2 & Doctrine: Create Custom SQL-Query
Get the Text of the Selected Option Using PHP
Laravel 4.2 Says My Application Is in Production. How to Turn This Off
Pdo Prepared Statements for Insert and on Duplicate Key Update with Named Placeholders
What Is an Appropriate Content-Type Header for JavaScript Files