SplObjectStorage::valid

(PHP 5 >= 5.1.0)

SplObjectStorage::validReturns if the current iterator entry is valid

說明

public bool SplObjectStorage::valid ( void )

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

參見

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top