update : 2015.11.03
php.shukuma.com

검색:
 
 
Checks if iterateable

ReflectionClass::isIterateable

(PHP 5)

ReflectionClass::isIterateableChecks if iterateable

설명

public bool ReflectionClass::isIterateable ( void )

Checks whether the class is iterateable.

인수

이 함수는 인수가 없습니다.

반환값

성공 시 TRUE를, 실패 시 FALSE를 반환합니다.

예제

Example #1 ReflectionClass::isIterateable() example

<?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)

참고