SimpleXMLIterator::valid
SimpleXMLIterator::valid
(PHP 5 >= 5.1.0, PHP 7)
SimpleXMLIterator :: valid - 检查当前元素是否有效
描述
public bool SimpleXMLIterator::valid ( void )
此方法在调用SimpleXMLIterator :: rewind()或SimpleXMLIterator :: next()之后检查当前元素是否有效。
参数
该功能没有参数。
返回值
如果当前元素有效,则返回TRUE,否则返回FALSE
例子
Example#1 检查当前元素是否有效
<?php
$xmlIterator = new SimpleXMLIterator('<books><book>SQL Basics</book></books>'
$xmlIterator->rewind( // rewind to the first element
echo var_dump($xmlIterator->valid() // bool(true)
$xmlIterator->next( // advance to the next element
echo var_dump($xmlIterator->valid() // bool(false) because there is only one element
?>
← SimpleXMLIterator::rewind