#48142 [NEW]: Confusing behavior
| From: | smh at wannafind dot dk | Date: | Mon, 04 May 2009 09:46:45 +0000 |
| Subject: | #48142 [NEW]: Confusing behavior | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-136713@lists.php.net to get a copy of this message | ||
From: smh at wannafind dot dk
Operating system: Linux 2.6.24.3-50.fc8
PHP version: 5.2.9
PHP Bug Type: Feature/Change Request
Bug description: Confusing behavior
Description:
------------
Requesting a string index on a string type using the string as an array
always returns first character position in string.
Reproduce code:
---------------
<?php
$input = '386';
echo $input . " / " . $input['tessrthwsrtht'] . "\n";
?>
Expected result:
----------------
PHP should generate an error when this occurs, because this situation
occurs when you think a method/function returns a string indexed array but
really just returns a string.
In this situation you get some data, but the data is incorrect and this
can be very confusing to debug.
Actual result:
--------------
PHP casts the string index to an integer with the value: 0 and returns the
first character in the string.
--
Edit bug report at http://bugs.php.net/?id=48142&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48142&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48142&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48142&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=48142&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48142&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=48142&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=48142&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=48142&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=48142&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=48142&r=support
Expected behavior: http://bugs.php.net/fix.php?id=48142&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=48142&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=48142&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=48142&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48142&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48142&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=48142&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=48142&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=48142&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=48142&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=48142&r=mysqlcfg