|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-03-31 21:49 UTC] php at alterego dot dp dot ua
Description:
------------
Strings offsets in PHP5 are broken strangely. Seems like repeated offsets are not allowed at all, even at the times where they make good sense.
I see nothing fatal in $a[0][0] or even $a{0}{0} or even $a[0]{0}[0] if $a is a non-empty string. And PHP5 just crashes at any one of them.
Why $a{0} can't be a string without extra intermediate assignment?
Please, look at the code before marking bogus.
Reproduce code:
---------------
<?
$a = '0';
$b = $a[0];
echo $b[0];
$a = '0';
// leave any one line of the next few
echo $a[0][0];
echo $a[0]{0};
echo $a{0}{0};
echo $a[0]{0}[0];
?>
Expected result:
----------------
00
Actual result:
--------------
0
Fatal error: Cannot use string offset as an array in /www/test.php on line 8
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 12:00:01 2025 UTC |
I do not expect PHP5 to be PHP4. I just expect it to be consistent in some way. Would you please be so kind as to give me a gentle hint of what is wrong with $a{0}{0} (CURLY BRACES). Thanks!