Home » Php » windows – php 64 bit with php_int_max = 2147483647

windows – php 64 bit with php_int_max = 2147483647

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have install WampServer 2.0 that has apache 2.4.4, mysql 5.6.12, and php 5.4.12. When I echo PHP_INT_MAX it gave me 2147483647. I have also echo phpinfo() and the architecture indicates x64. This suppose to be not happening because my php is 64 bit right? I need my php to support 64 bit integer. I need my PHP_INT_MAX to be 9223372036854775807.

Can somebody help me? Thanks

How to&Answers:

If you’re running a windows OS, wampServer suggests you are, this is your answer:

On windows x86_64, PHP_INT_MAX is 2147483647. This is because in the
underlying c-code, a long is 32 bit.

Note that this doesn’t mean that Windows doesn’t support 64bit int’s: int64_t does exist, but it’s not used by PHP AFAIK.
I’ve managed to come up with this link, on that page, there’s some code you might be able to use, to add support for 64bit ints to your code

Answer:

In the file RequestUtil.php, it does the following check:

if (strlen((string) PHP_INT_MAX) < 19) {
    // Looks like we're running on a 32-bit build of PHP.  This could cause problems because some of the numbers
    // we use (file sizes, quota, etc) can be larger than 32-bit ints can handle.
    throw new \Exception("The Dropbox SDK uses 64-bit integers, but it looks like we're running on a version of PHP that doesn't support 64-bit integers (PHP_INT_MAX=" . ((string) PHP_INT_MAX) . ").  Library: \"" . __FILE__ . "\"");
}

You can comment it out and try hacking your way from there.

If I were you, I’d write my own Dropbox API implementation using strings and not integers.

PS: But this is what I do so I enjoy it 🙂

Answer:

Try PHP7 – the current master http://windows.php.net/downloads/snaps/master/ . 64-bit builds now exploit all the capabilities of the 64-bit Windows.

Answer:

Go to ‘vendor/dropbox/dropbox-sdk/lib/Dropbox’
and comment lines 19-23 in RequestUtil.php.

Comment this section:

/*if (strlen((string) PHP_INT_MAX) < 19) {
    // Looks like we're running on a 32-bit build of PHP.  This could cause problems because some of the numbers
    // we use (file sizes, quota, etc) can be larger than 32-bit ints can handle.
    throw new \Exception("The Dropbox SDK uses 64-bit integers, but it looks like we're running on a version of PHP that doesn't support 64-bit integers (PHP_INT_MAX=" . ((string) PHP_INT_MAX) . ").  Library: \"" . __FILE__ . "\"");
}*/

That’s it.

Answer:

I tried php7 and it worked:

running php.exe -r "echo PHP_INT_MAX;"

and it outputs 9223372036854775807