array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'reflectionclass.getconstructor.php', 1 => 'ReflectionClass::getConstructor', 2 => 'Gets the constructor of the class', ), 'up' => array ( 0 => 'class.reflectionclass.php', 1 => 'ReflectionClass', ), 'prev' => array ( 0 => 'reflectionclass.getconstants.php', 1 => 'ReflectionClass::getConstants', ), 'next' => array ( 0 => 'reflectionclass.getdefaultproperties.php', 1 => 'ReflectionClass::getDefaultProperties', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/reflection/reflectionclass/getconstructor.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 5, PHP 7, PHP 8)
ReflectionClass::getConstructor — Gets the constructor of the class
Gets the constructor of the reflected class.
У цієї функції немає параметрів.
A ReflectionMethod object reflecting the class' constructor, or null if the class
has no constructor.
Приклад #1 Basic usage of ReflectionClass::getConstructor()
<?php
$class = new ReflectionClass('ReflectionClass');
$constructor = $class->getConstructor();
var_dump($constructor);
?>Поданий вище приклад виведе:
object(ReflectionMethod)#2 (2) {
["name"]=>
string(11) "__construct"
["class"]=>
string(15) "ReflectionClass"
}