Re: Re: 64bit and phpng, votes and plans
| From: | Yasuo Ohgaki | Date: | Tue, 20 May 2014 20:45:43 +0000 |
| Subject: | Re: Re: 64bit and phpng, votes and plans | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-74387@lists.php.net to get a copy of this message | ||
Hi Nikita,
On Tue, May 20, 2014 at 4:09 PM, Nikita Popov <nikita.ppv@gmail.com> wrote:
> You can already use a key larger than 32 bits to index an array. The
> limitation only applies if you want to actually store more than 2^32 (or
> 2^31 depending on the exact implementation) elements. That's the beauty of
> a hashtable: The allowed key domain is totally independent of the hashtable
> size ;)
>
Right and wrong.
When key is string, key can be anything. However, when it is int, it's not.
$ php -r '$arr[9999999999999999999999999999999]="abc";var_dump($arr);'
array(1) {
[-4571153621781053440]=>
string(3) "abc"
}
$ php -r
'$arr["9999999999999999999999999999999"]="abc";var_dump($arr);'
array(1) {
["9999999999999999999999999999999"]=>
string(3) "abc"
}
This is the reason why convert DB data values and Web inputs should not be
converted to native PHP data type blindly :)
It could work, but it cannot with 64bit int.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net