ReflectionClass::getConstructor
PHP function
Edit on GitHub ✎
(PHP 5, PHP 7, PHP 8)
Gets the constructor of the class
Description
ReflectionClass::getConstructor(): ReflectionMethod|null
Gets the constructor of the reflected class.
Parameters Parameters
Return Values
A ReflectionMethod object reflecting the class' constructor, or null if the class has no constructor.
Examples
Basic usage of ReflectionClass::getConstructor
php
<?php
$class = new ReflectionClass('ReflectionClass');
$constructor = $class->getConstructor();
var_dump($constructor);
?>The above example will output:
output
object(ReflectionMethod)#2 (2) {
["name"]=>
string(11) "__construct"
["class"]=>
string(15) "ReflectionClass"
}See Also
ReflectionClass::getName