SplObjectStorage::valid

(PHP 5 >= 5.1.0, PHP 7)

SplObjectStorage::validReturns if the current iterator entry is valid

说明

public SplObjectStorage::valid ( void ) : bool

Returns if the current iterator entry is valid.

参数

此函数没有参数。

返回值

Returns TRUE if the iterator entry is valid, FALSE otherwise.

范例

Example #1 SplObjectStorage::valid() example

<?php
$s 
= new SplObjectStorage();

$o1 = new StdClass;
$o2 = new StdClass;

$s->attach($o1"d1");
$s->attach($o2"d2");

$s->rewind();
while(
$s->valid()) {
    echo 
$s->key()."\n";
    
$s->next();
}
?>

以上例程的输出类似于:

0
1

参见

相关文章
php apcuiterator checks if current position is validphp mysqlnd qc 函数 returns information on the current handler the number of cache entries and cache entries if availablephp intliterator check if current position is validphp outeriterator returns the inner iterator for the current entryphp pharfileinfo uncompresses the current phar entry within the phar if it is compressedphp recursivearrayiterator returns an iterator for the current entry if it is an array or an objectphp recursivearrayiterator returns whether current entry is an array or an objectphp recursivedirectoryiterator returns an iterator for the current entry if it is a directoryphp recursivedirectoryiterator returns whether current entry is a directory and not . or .. php recursiveiterator returns an iterator for the current entryphp recursiveiterator returns if an iterator can be created for the current entryphp recursiveregexiterator returns an iterator for the current entryphp recursiveregexiterator returns whether an iterator can be obtained for the current entryphp solrdocument checks if the current position internally is still validphp splobjectstorage returns the current storage entryphp splobjectstorage returns the data associated with the current iterator entryphp splobjectstorage sets the data associated with the current iterator entryphp splobjectstorage returns if the current iterator entry is validphp swoole connection iterator return current connection entry.php swoole connection iterator check if current position is valid.
关注编程学问公众号