array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'reflectionclass.isiterable.php', 1 => 'ReflectionClass::isIterable', ), 'up' => array ( 0 => 'class.reflectionclass.php', 1 => 'ReflectionClass', ), 'prev' => array ( 0 => 'reflectionclass.isinternal.php', 1 => 'ReflectionClass::isInternal', ), 'next' => array ( 0 => 'reflectionclass.isiterateable.php', 1 => 'ReflectionClass::isIterateable', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'tr', 'path' => 'reference/reflection/reflectionclass/isiterable.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7 >= 7.2.0, PHP 8)
ReflectionClass::isIterable — Sınıf yinelenebilir mi diye bakar
Sınıf yinelenebilir mi (yani foreach içinde kullanılabilir mi) diye bakar.
Bu işlevin bağımsız değişkeni yoktur.
Ö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)