vrana Sun Mar 20 05:16:35 2005 EDT
Modified files:
/phpdoc/en/reference/array/functions count.xml
Log:
Doesn't count object members (bug #31977)
http://cvs.php.net/diff.php/phpdoc/en/reference/array/functions/count.xml?r1=1.15&r2=1.16&ty=u
Index: phpdoc/en/reference/array/functions/count.xml
diff -u phpdoc/en/reference/array/functions/count.xml:1.15
phpdoc/en/reference/array/functions/count.xml:1.16
--- phpdoc/en/reference/array/functions/count.xml:1.15 Wed Nov 3 02:30:01 2004
+++ phpdoc/en/reference/array/functions/count.xml Sun Mar 20 05:16:34 2005
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.15 $ -->
+<!-- $Revision: 1.16 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
<refentry id="function.count">
<refnamediv>
@@ -15,12 +15,11 @@
</methodsynopsis>
<para>
Returns the number of elements in <parameter>var</parameter>,
- which is typically an <type>array</type>, since anything other than
objects
+ which is typically an <type>array</type>, since anything other
will have one element.
</para>
<para>
- For objects <function>count</function> will return the number of non
static
- properties, not taking visibility into account. If you have
+ For objects, if you have
<link linkend="ref.spl">SPL</link> installed, you can hook into
<function>count</function> by implementing interface
<literal>Countable</literal>. The interface has exactly one method,
@@ -28,7 +27,8 @@
<function>count</function> function.
</para>
<para>
- If <parameter>var</parameter> is not an array or an object,
+ If <parameter>var</parameter> is not an array or an object with
+ implemented <literal>Countable</literal> interface,
<literal>1</literal> will be returned.
There is one exception, if <parameter>var</parameter> is &null;,
<literal>0</literal> will be returned.
@@ -76,19 +76,13 @@
$b[5] = 9;
$b[10] = 11;
$result = count($b);
-// $result == 3;
+// $result == 3
$result = count(null);
-// $result == 0;
+// $result == 0
$result = count(false);
-// $result == 1;
-
-$obj = new StdClass;
-$obj->foo = 'A property';
-$obj->bar = 'Another property';
-$result = count($obj);
-// $result == 2;
+// $result == 1
?>
]]>
</programlisting>
@@ -97,7 +91,7 @@
<para>
<example>
<title>
- recursive <function>count</function> example (PHP >= 4.2.0)
+ Recursive <function>count</function> example (PHP >= 4.2.0)
</title>
<programlisting role="php">
<![CDATA[
@@ -106,10 +100,10 @@
'veggie' => array('carrot', 'collard', 'pea'));
// recursive count
-echo count($food, COUNT_RECURSIVE); // output 8
+echo count($food, COUNT_RECURSIVE); // output 8
// normal count
-echo count($food); // output 2
+echo count($food); // output 2
?>
]]>