#31399 [Bgs]: PHP5 incorrect count description

From: Date: Tue, 04 Jan 2005 20:51:20 +0000
Subject: #31399 [Bgs]: PHP5 incorrect count description
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969365820@lists.php.net to get a copy of this message
ID: 31399 Updated by: sean@php.net Reported By: sveta at microbecal dot com Status: Bogus Bug Type: Documentation problem PHP Version: 5CVS-2005-01-04 (dev) New Comment: sean@iconoclast:~$ echo '<?php error_reporting(E_ALL); echo PHP_VERSION ."\n". count($a) ."\n"; ?>' | php Notice: Undefined variable: a in - on line 1 4.3.4 0 sean@iconoclast:~$ echo '<?php error_reporting(E_ALL); echo PHP_VERSION ."\n". count($a) ."\n"; ?>' | php5 Notice: Undefined variable: a in - on line 1 5.0.3 0 I agree with Nuno: E_NOTICE on undefined variable access is (almost) global, so we should not start documenting this everywhere. 5.0.3 DOES return 0 if undefined. Derick: If something changed, what is it? S Previous Comments: ------------------------------------------------------------------------ [2005-01-04 21:36:07] nlopess@php.net I don't agree with that change, because if we add such info to count() we would have to add it to all functions. If you use an uninitialized var in PHP, you will get a E_NOTICE. This isn't specific to count(). Nuno ------------------------------------------------------------------------ [2005-01-04 18:49:30] 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 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] nlopess@php.net 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] derick@php.net That was not the point Nuno, thebehavior changed regarding non-initialized values..that can be documented just fine. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/31399 -- Edit this bug report at http://bugs.php.net/?id=31399&edit=1

« previous php.doc (#969365820) next »