PHP | ReflectionClass isIterateable() Function
Last Updated :
05 Dec, 2019
The ReflectionClass::isIterateable() function is an inbuilt function in PHP which is used to check if the defined class is iterateable or not.
Syntax:
bool ReflectionClass::isIterateable()
Parameters: This function does not accept any parameter.
Return Value: This function returns TRUE if the defined class is iterateable, otherwise FALSE.
Below programs illustrate the ReflectionClass::isIterateable() function in PHP:
Program 1:
<?php
class p implements Iterator {
public function rewind () {}
public function next() {}
public function valid() {}
public function current() {}
public function key() {}
}
$class = new ReflectionClass( 'p' );
$A = $class ->isIterateable();
var_dump( $A );
?>
|
Output:
bool(true)
Program 2:
<?php
class p {
public function getIterator() {}
}
$class = new ReflectionClass( 'p' );
$A = $class ->isIterateable();
var_dump( $A );
?>
|
Output:
bool(false)
Reference: https://www.php.net/manual/en/reflectionclass.isiterateable.php
Share your thoughts in the comments
Please Login to comment...