Hàm current () trong PHP
Thí dụ
Tua lại phần tử đầu tiên và sau đó trả lại nó bằng hàm current ():
<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Do not forget me this weekend!</body>
</note>
XML;
$xml = new SimpleXMLIterator($note);
// rewind to the first element
$xml->rewind();
// return current element
var_dump($xml->current());
?>
Định nghĩa và Cách sử dụng
Hàm current () trả về phần tử hiện tại.
Cú pháp
SimpleXMLIterator::current()
Chi tiết kỹ thuật
Giá trị trả lại: | Phần tử hiện tại (dưới dạng đối tượng SimpleXMLIterator) thành công. NULL khi thất bại |
---|---|
Phiên bản PHP: | 5.0+ |
❮ Tham chiếu PHP SimpleXML