ReflectionClass::isIterable

(PHP 7 >= 7.2.0, PHP 8)

ReflectionClass::isIterableSınıf yinelenebilir mi diye bakar

Açıklama

public ReflectionClass::isIterable(): bool

Sınıf yinelenebilir mi (yani foreach içinde kullanılabilir mi) diye bakar.

Değiştirgeler

Bu işlevin değiştirgesi yoktur.

Dönen Değerler

Başarı durumunda true, başarısızlık durumunda false döner.

Örnekler

Örnek 1 - ReflectionClass::isIterable() temel kullanım örneği

<?php

class IteratorClass implements Iterator {
    public function 
__construct() { }
    public function 
key() { }
    public function 
current() { }
    function 
next() { }
    function 
valid() { }
    function 
rewind() { }
}
class 
DerivedClass extends IteratorClass { }
class 
NonIterator { }

function 
dump_iterable($class) {
    
$reflection = new ReflectionClass($class);
    
var_dump($reflection->isIterable());
}

$classes = array("ArrayObject""IteratorClass""DerivedClass""NonIterator");

foreach (
$classes as $class) {
    echo 
"$class yinelenebiliyor mu?? ";
    
dump_iterable($class);
}
?>

Yukarıdaki örneğin çıktısı:

ArrayObject yinelenebiliyor mu?? bool(true)
IteratorClass yinelenebiliyor mu?? bool(true)
DerivedClass yinelenebiliyor mu?? bool(true)
NonIterator yinelenebiliyor mu?? bool(false)

Ayrıca Bakınız

add a note add a note

User Contributed Notes

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