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 imagickpixeliterator returns the current pixel iterator rowphp iteratoriterator checks if the iterator is validphp outeriterator returns the inner iterator for the current entryphp recursivearrayiterator returns an iterator for the current entry if it is an array or an objectphp recursivedirectoryiterator returns an iterator for the current entry if it is a directoryphp 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 splobjectstorage returns the current storage entryphp splobjectstorage returns the data associated with the current iterator entryphp splobjectstorage returns the index at which the iterator currently isphp splobjectstorage sets the data associated with the current iterator entryphp splobjectstorage returns if the current iterator entry is validphp swftext returns the ascent of the current font at its current size or 0 if not availablephp swftext returns the descent of the current font at its current size or 0 if not availablephp swftext returns the leading of the current font at its current size or 0 if not availablephp swoole connection iterator check if current position is valid.php swoole table check current if the current row is valid.php weakmap returns whether the iterator is still on a valid map element
关注编程学问公众号