PHP | ReflectionClass getReflectionConstants() Function
Last Updated :
30 Nov, 2019
The ReflectionClass::getReflectionConstants() function is an inbuilt function in PHP which is used to return an array of ReflectionClassConstant objects.
Syntax:
array ReflectionClass::getReflectionConstants( void )
Parameters: This function does not accept any parameters.
Return Value: This function returns an array of ReflectionClassConstant objects.
Below programs illustrate the ReflectionClass::getReflectionConstants() function in PHP:
Program 1:
<?php
class Company {
const First = "GeeksforGeeks" ;
const Second = "GFG" ;
}
$A = new ReflectionClass( 'Company' );
$a = $A ->getReflectionConstants();
print_r( $a );
?>
|
Output:
Array
(
[0] => ReflectionClassConstant Object
(
[name] => First
[class] => Company
)
[1] => ReflectionClassConstant Object
(
[name] => Second
[class] => Company
)
)
Program 2:
<?php
$A = new ReflectionClass( 'ReflectionClass' );
$a = $A ->getReflectionConstants();
print_r( $a );
?>
|
Output:
Array
(
[0] => ReflectionClassConstant Object
(
[name] => IS_IMPLICIT_ABSTRACT
[class] => ReflectionClass
)
[1] => ReflectionClassConstant Object
(
[name] => IS_EXPLICIT_ABSTRACT
[class] => ReflectionClass
)
[2] => ReflectionClassConstant Object
(
[name] => IS_FINAL
[class] => ReflectionClass
)
)
Reference: https://secure.php.net/manual/en/reflectionclass.getreflectionconstants.php
Share your thoughts in the comments
Please Login to comment...