mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Fixed #50864 (SimpleXMLElement::count does not exist)
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@295784 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
091df5f2d1
commit
78071bae5a
3 changed files with 106 additions and 2 deletions
|
@ -175,7 +175,8 @@ int(1)
|
|||
<methodname>SimpleXMLElement::children</methodname> returns a node
|
||||
object no matter if the current node has children or not. Use
|
||||
<function>count</function> on the return value to see if there are any
|
||||
children.
|
||||
children. As of PHP 5.3.0, <methodname>SimpleXMLElement::count</methodname>
|
||||
may be used instead.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
|
||||
|
@ -183,6 +184,7 @@ int(1)
|
|||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><methodname>SimpleXMLElement::count</methodname></member>
|
||||
<member><function>count</function></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
|
|
101
reference/simplexml/simplexmlelement/count.xml
Normal file
101
reference/simplexml/simplexmlelement/count.xml
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="simplexmlelement.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>SimpleXMLElement::count</refname>
|
||||
<refpurpose>Counts the children of an element</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>integer</type><methodname>SimpleXMLElement::count</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
This method counts the number of children of an element.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns the number of elements of an element.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>Counting the number of children</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$xml = <<<EOF
|
||||
<people>
|
||||
<person name="Person 1">
|
||||
<child/>
|
||||
<child/>
|
||||
<child/>
|
||||
</person>
|
||||
<person name="Person 2">
|
||||
<child/>
|
||||
<child/>
|
||||
<child/>
|
||||
<child/>
|
||||
<child/>
|
||||
</person>
|
||||
</people>
|
||||
EOF;
|
||||
|
||||
$elem = new SimpleXMLElement($xml);
|
||||
|
||||
foreach ($elem as $person) {
|
||||
printf("%s has got %d children.\n", $person['name'], $person->count());
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Person 1 has got 3 children.
|
||||
Person 2 has got 5 children.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><methodname>SimpleXMLElement::children</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
|
||||
-->
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
<function name='simplexmlelement::asxml' from='PHP 5 >= 5.0.1'/>
|
||||
<function name='simplexmlelement::attributes' from='PHP 5 >= 5.0.1'/>
|
||||
<function name='simplexmlelement::children' from='PHP 5 >= 5.0.1'/>
|
||||
<function name='simplexmlelement::count' from='PHP 5 >= 5.3.0'/>
|
||||
<function name='simplexmlelement::getdocnamespaces' from='PHP 5 >= 5.1.2'/>
|
||||
<function name='simplexmlelement::getname' from='PHP 5 >= 5.1.3'/>
|
||||
<function name='simplexmlelement::getnamespaces' from='PHP 5 >= 5.1.2'/>
|
||||
|
@ -49,4 +50,4 @@ End:
|
|||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
||||
-->
|
||||
|
|
Loading…
Reference in a new issue