ReflectionClass::isIterateable

(PHP 5, PHP 7)

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)

참고

add a note add a note

User Contributed Notes 1 note

up
0
o at olgierd dot me
5 years ago
In https://github.com/php/php-src/blob/879cd0491399ccfacac0d6ed701d998a65a6cc97/ext/reflection/php_reflection.c we can see that ReflectionClass::isIterateable() is an alias for ReflectionClass::isIterable().
To Top