Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php 64 bit with php_int_max = 2147483647

Tags:

php

int

windows

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

like image 663
mikellez Avatar asked Jul 24 '13 14:07

mikellez


2 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

like image 50
Elias Van Ootegem Avatar answered Sep 29 '22 14:09

Elias Van Ootegem


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 :)

like image 20
CodeAngry Avatar answered Sep 29 '22 12:09

CodeAngry