ID:               45290
 Updated by:       [EMAIL PROTECTED]
 Reported By:      cole dot snodgrass at gmail dot com
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: linux
 PHP Version:      5.2.6
 New Comment:

FWIW: $string['foo'] is equivalent to $string[0] and in your case it
won't trigger any notice indeed because the offset 0 is defined.


Previous Comments:
------------------------------------------------------------------------

[2008-06-17 04:24:15] cole dot snodgrass at gmail dot com

Description:
------------
It seems strange that when the strictest level or error reporting is
enabled an E_NOTICE is thrown when attempting to access a non-existent
key of an array, but nothing is thrown when attempting to access a
non-existent key of a bool, or a string, or it appears any other
variable type.  An E_NOTICE will also be thrown if attempting to access
a non-existent numerical key in a string, but not if attempting to
access a non-existent non-numerical key.

If an E_NOTICE is displayed under one circumstance for an index not
existing it seems that it should be displayed under all circumstances
when an index doesn't exist.

Reproduce code:
---------------
error_reporting(E_ALL | E_STRICT);

$dummyArray = array();
// this will throw an E_NOTICE
$error = $dummyArray['doesNotExist'];

$dummyArray = true;
// this will not throw an E_NOTICE
$noError = $dummyArray['doesNotExist'];

$dummyArray = 'string';
// this will not throw an E_NOTICE
$noError = $dummyArray['doesNotExist'];
// but this will throw an E_NOTICE
$error = $dummaryArray['100'];


Expected result:
----------------
Notice: Undefined index: doesNotExist
Notice: Undefined index: doesNotExist
Notice: Undefined index: doesNotExist
Notice: Uninitialized string offset:  100

Actual result:
--------------
Notice: Undefined index: doesNotExist
< nothing when attempting to access a non-existent key of a bool >
< nothing when attempting to access a non-existent key of a string >
Notice: Uninitialized string offset:  100


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45290&edit=1

Reply via email to