ReflectionClass::getConstructor

(PHP 5, PHP 7)

ReflectionClass::getConstructor获取类的构造函数

说明

public ReflectionClass::getConstructor ( void ) : ReflectionMethod

获取已反射的类的构造函数。

参数

此函数没有参数。

返回值

一个 ReflectionMethod 对象,反射了类的构造函数,或者当类不存在构造函数时返回 NULL

范例

Example #1 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"
}

参见