ReflectionClass::isIterateable

(PHP 5, PHP 7)

ReflectionClass::isIterateable锟斤拷锟斤拷欠锟缴碉拷锟斤拷锟斤拷iterateable锟斤拷

说锟斤拷

public ReflectionClass::isIterateable ( void ) : bool

锟斤拷锟揭伙拷锟斤拷锟斤拷欠锟缴碉拷锟斤拷锟斤拷iterateable锟斤拷锟斤拷

锟斤拷锟斤拷

锟剿猴拷锟斤拷没锟叫诧拷锟斤拷锟斤拷

锟斤拷锟斤拷值

锟缴癸拷时锟斤拷锟斤拷 TRUE锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE锟斤拷

锟斤拷锟斤拷

Example #1 ReflectionClass::isIterateable() 锟斤拷锟斤拷

<?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_iterateable($class) {
    
$reflection = new ReflectionClass($class);
    
var_dump($reflection->isIterateable());
}

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

foreach (
$classes as $class) {
    echo 
"Is $class iterateable? ";
    
dump_iterateable($class);
}
?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

Is ArrayObject iterateable? bool(true)
Is IteratorClass iterateable? bool(true)
Is DerivedClass iterateable? bool(true)
Is NonIterator iterateable? bool(false)

锟轿硷拷