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 imagick checks if the current item is validphp 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 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 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 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 return current connection entry.php swoole connection iterator check if current position is valid.php weakmap returns whether the iterator is still on a valid map element
关注编程学问公众号