#38165 [Bgs]: no error to return non-existent index of a non-array variable
| From: | aurelien dot riche at ac-lille dot fr | Date: | Fri, 21 Jul 2006 07:11:16 +0000 |
| Subject: | #38165 [Bgs]: no error to return non-existent index of a non-array variable | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-99703@lists.php.net to get a copy of this message | ||
ID: 38165
User updated by: aurelien dot riche at ac-lille dot fr
Reported By: aurelien dot riche at ac-lille dot fr
Status: Bogus
Bug Type: Arrays related
Operating System: linux
PHP Version: 5.1.4
New Comment:
OK thanks.
I suppose I should do this test instead of before:
if(is_array($var['index']))
echo 'OK';
Previous Comments:
------------------------------------------------------------------------
[2006-07-20 16:00:37] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
$var[0] is perfectly valid and 'index' is autoconverted to 0.
------------------------------------------------------------------------
[2006-07-20 15:58:31] aurelien dot riche at ac-lille dot fr
Description:
------------
There's no error reporting for this code below...
'index' is interpreted as 1 and the value returned is the first letter
of string 'hello world'
If it's a normal behavior, can you specify this in the documentation ?
Reproduce code:
---------------
$var = 'hello world';
echo $var['index'];
echo '<br/><br/>';
if(isset($var['index']))
echo 'OK';
Expected result:
----------------
Notice: Undefined offset: 'index'
Actual result:
--------------
h
OK
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38165&edit=1