ID:              31399
 User updated by: sveta at microbecal dot com
 Reported By:     sveta at microbecal dot com
-Status:          Bogus
+Status:          Open
 Bug Type:        Documentation problem
 PHP Version:     5CVS-2005-01-04 (dev)
 New Comment:

OK Lets correct "patch" to:

--- 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.
+      <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>

or to something with similar sence, but better style English


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

[2005-01-04 18:49:22] sveta at microbecal dot com

OK Lets correct "patch" to:

--- 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.
+      <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>

or to something with similar sence, but better style English

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

[2005-01-04 17:00:06] [EMAIL PROTECTED]

PHP 4 also gives a warning:

C:\php4>php-cli -r "error_reporting(E_ALL); echo count($a);"

Notice: Undefined variable:  a in Command line code on line 1
0

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

[2005-01-04 12:46:58] [EMAIL PROTECTED]

That was not the point Nuno, thebehavior changed regarding
non-initialized values..that can be documented just fine.

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

[2005-01-04 12:15:09] [EMAIL PROTECTED]

It stills return 0.
Try echoing its value with: '<? echo count($a); ?>'

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

[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

Reply via email to