#31399 [Opn->Bgs]: PHP5 incorrect count description
| From: | nlopess@php.net | Date: | Tue, 04 Jan 2005 11:15:10 +0000 |
| Subject: | #31399 [Opn->Bgs]: PHP5 incorrect count description | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969365808@lists.php.net to get a copy of this message | ||
ID: 31399
Updated by: nlopess@php.net
Reported By: sveta at microbecal dot com
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
PHP Version: 5CVS-2005-01-04 (dev)
New Comment:
It stills return 0.
Try echoing its value with: '<? echo count($a); ?>'
Previous Comments:
------------------------------------------------------------------------
[2005-01-04 00:27:25] sveta at microbecal dot com
Description:
------------
In function.count I see:
"count() may return 0 for a variable that isn't set", but is not true
with PHP5 with E_NOTICE turned on
I have tried to patch it:
--- count.xml 2004-11-03 10:30:02.000000000 +0300
+++ count_new.xml 2005-01-01 19:45:24.000000000 +0300
@@ -53,6 +53,8 @@
isn't set, but it may also return 0 for a variable that has
been initialized with an empty array. Use
<function>isset</function> to test if a variable is set.
+ Since PHP 5.0.0, <function>count</function> generates warning of
level
+ <link linkend="errorfunc.constants">E_NOTICE</link> in case of
taking non-initialized variable as parameter.
</para>
</caution>
<para>
Reproduce code:
---------------
count($x);
Expected result:
----------------
0
Actual result:
--------------
Notice: Undefined variable: x in D:\My
Documents\web_project\PHP.lessons\www\reflection.php on line 3
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31399&edit=1