From:             cole dot snodgrass at gmail dot com
Operating system: linux
PHP version:      5.2.6
PHP Bug Type:     Feature/Change Request
Bug description:  always throw an E_NOTICE when accessing an undefined index

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 bug report at http://bugs.php.net/?id=45290&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45290&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45290&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45290&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45290&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45290&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45290&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45290&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45290&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45290&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45290&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45290&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45290&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45290&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45290&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45290&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45290&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45290&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45290&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45290&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45290&r=mysqlcfg

Reply via email to