php-doc-en/reference/spl/splobjectstorage/count.xml

106 lines
2.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="splobjectstorage.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SplObjectStorage::count</refname>
<refpurpose>Returns the number of objects in the storage</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>int</type><methodname>SplObjectStorage::count</methodname>
<methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer><constant>COUNT_NORMAL</constant></initializer></methodparam>
</methodsynopsis>
<para>
Counts the number of objects in the storage.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>mode</parameter></term>
<listitem>
<para>
If the optional <parameter>mode</parameter> parameter is set to
<constant>COUNT_RECURSIVE</constant> (or 1), <function>SplObjectStorage::count</function>
will recursively count the storage.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The number of objects in the storage.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>SplObjectStorage::count</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$s = new SplObjectStorage();
$o1 = new StdClass;
$o2 = new StdClass;
$s->attach($o1);
$s->attach($o2);
$s->attach($o1);
var_dump($s->count());
var_dump(count($s));
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
int(2)
int(2)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>SplObjectStorage::attach</methodname></member>
<member><methodname>SplObjectStorage::detach</methodname></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->