array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'simplexmlelement.haschildren.php', 1 => 'SimpleXMLElement::hasChildren', 2 => 'Checks whether the current element has sub elements', ), 'up' => array ( 0 => 'class.simplexmlelement.php', 1 => 'SimpleXMLElement', ), 'prev' => array ( 0 => 'simplexmlelement.getchildren.php', 1 => 'SimpleXMLElement::getChildren', ), 'next' => array ( 0 => 'simplexmlelement.key.php', 1 => 'SimpleXMLElement::key', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/simplexml/simplexmlelement/haschildren.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 8)
SimpleXMLElement::hasChildren — Checks whether the current element has sub elements
Prior to PHP 8.0, SimpleXMLElement::hasChildren() was only declared on the subclass SimpleXMLIterator.
This method checks whether the current SimpleXMLElement element has sub-elements.
Bu işlevin bağımsız değişkeni yoktur.
Örnek 1 Check whether the current element has sub-elements
<?php
$xml = <<<XML
<books>
<book>
<title>PHP Basics</title>
<author>Jim Smith</author>
</book>
<book>XML basics</book>
</books>
XML;
$xmlElement = new SimpleXMLElement($xml);
for ($xmlElement->rewind(); $xmlElement->valid(); $xmlElement->next()) {
if ($xmlElement->hasChildren()) {
var_dump($xmlElement->current());
}
}
?>Yukarıdaki örneğin çıktısı:
object(SimpleXMLElement)#2 (2) {
["title"]=>
string(10) "PHP Basics"
["author"]=>
string(9) "Jim Smith"
}