(No version information available, might only be in Git)
SimpleXMLElement::key — Return current key
Prior to PHP 8.0, SimpleXMLElement::key() was only declared on the subclass SimpleXMLIterator.
This method gets the XML tag name of the current element.
Bu işlevin bağımsız değişkeni yoktur.
Returns the XML tag name of the element referenced by the current SimpleXMLElement object.
Throws an Error on failure.
Sürüm: | Açıklama |
---|---|
8.1.0 |
An Error is now thrown if
SimpleXMLElement::key() is called on an
invalid iterator. Previously, false was returned.
|
Örnek 1 Get the current XML tag key
<?php
$xmlElement = new SimpleXMLElement('<books><book>PHP basics</book><book>XML basics</book></books>');
echo var_dump($xmlElement->key());
$xmlElement->rewind(); // rewind to the first element
echo var_dump($xmlElement->key());
?>
Yukarıdaki örneğin çıktısı:
bool(false) string(4) "book"