ReflectionClass::isIterateable
ReflectionClass::isIterateable
(PHP 5, PHP 7)
ReflectionClass::isIterateable — 检查是否可迭代
描述
public bool ReflectionClass::isIterateable ( void )
检查该类是否可迭代。
参数
该函数没有参数。
返回值
成功时返回TRUE
或失败时返回FALSE
。
例子
示例#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)
另请参阅
- ReflectionClass::__construct() - 构造一个ReflectionClass
← ReflectionClass::isInternal
ReflectionClass::isSubclassOf →