string can reach 2 GB.
It looks like it really is (2GB - 1). This works fine on my x64 field:
$str = str_repeat('a', 2 * 1024 * 1024 * 1024 -1); echo $str[0];
... while this is interrupted:
$str = str_repeat('a', 2 * 1024 * 1024 * 1024); echo $str[0];
What you do is simply undefined and the manual should be fixed. I would also expect a warning.
Interestingly, this leads to a fatal error:
$str = str_repeat('a', 2 * 1024 * 1024 * 1024 -2); // 2GB - 2 bytes $str .= 'b'; // ok $str .= 'c'; // PHP Fatal error: String size overflow
Update:
The report reports an error . The documentation on php.net has been fixed and now it says "maximum 2147483647 bytes."
RandomSeed Jul 10 '13 at 16:59 2013-07-10 16:59
source share