ID:               50225
 User updated by:  josh dot ribakoff at gmail dot com
 Reported By:      josh dot ribakoff at gmail dot com
 Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Windows Vista
 PHP Version:      5.3.0
 New Comment:

I disagree with your explanation because $foo['bar'] is never created
as $foo still equals NULL according to my debugger.

And to quote the manual:

"Note: Attempting to access an array key which has not been defined is
the same as accessing any other undefined variable: an E_NOTICE-level
error message will be issued, and the result will be NULL. "

I did RTFM, and it never said anything about trying to access a
variable causing it to be created. The explanation left in the related
bug you referenced is probably more accurate

"Note: Accessing variables of other types using [] or {} silently
returns NULL. "

Even if this is "by design" I still think it should generate a NOTICE,
where could I read about the design decisions of why it was done the way
it was? And would it be appropriate to re-categorize this as a feature
suggestion or do you guys not want to hear about it?


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

[2009-11-19 08:32:32] [email protected]

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

RTFM: 

http://php.net/count 

"There is one exception, if var  is NULL, 0 will be returned."

http://php.net/array

"Converting NULL to an array results in an empty array." 

See also bug #44821

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

[2009-11-19 07:54:09] josh dot ribakoff at gmail dot com

Description:
------------
Example A "compiles" and B does not (E_NOTICE).

Invoking an array index on NULL *probably* warrants my attention more
than doing so on an array.

It has cost me countless hours, for one.

Reproduce code:
---------------
// A
$foo = null;
count( $foo['bar'] );

// B
$foo = array();
count( $foo['bar'] );


Expected result:
----------------
2 E_NOTICE errors

Actual result:
--------------
1 E_NOTICE error


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


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

Reply via email to