|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-01-04 00:27 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 22:00:01 2025 UTC |
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 EnglishOK 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