#32522 [NEW]: String offsets REALLY weird
| From: | php at alterego dot dp dot ua | Date: | Thu, 31 Mar 2005 19:49:15 +0000 |
| Subject: | #32522 [NEW]: String offsets REALLY weird | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-76707@lists.php.net to get a copy of this message | ||
From: php at alterego dot dp dot ua
Operating system: FreeBSD 4.10
PHP version: 5.0.3
PHP Bug Type: Strings related
Bug description: String offsets REALLY weird
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
--
Edit bug report at http://bugs.php.net/?id=32522&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32522&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32522&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32522&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32522&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32522&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32522&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32522&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32522&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32522&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32522&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32522&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32522&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32522&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32522&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32522&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32522&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32522&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32522&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32522&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32522&r=mysqlcfg