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); ?>

ReflectionClass::getConstructor

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getConstructorGets the constructor of the class

Опис

public ReflectionClass::getConstructor(): ?ReflectionMethod

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"
}

Прогляньте також