#50225 [Opn->Bgs]: count() on undefined var does not trigger NOTICE
ID: 50225
Updated by: jani@php.net
Reported By: josh dot ribakoff at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows Vista
PHP Version: 5.3.0
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[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
Thread (3 messages)