(PHP 5, PHP 7, PHP 8)
ReflectionClass::getConstructor — 獲取類(lèi)的構造函數
此函數沒(méi)有參數。
一個(gè) ReflectionMethod 對象,反射了類(lèi)的構造函數,或者當類(lèi)不存在構造函數時(shí)返回 null
。
示例 #1 ReflectionClass::getConstructor() 的基本用法
<?php
$class = new ReflectionClass('ReflectionClass');
$constructor = $class->getConstructor();
var_dump($constructor);
?>
以上例程會(huì )輸出:
object(ReflectionMethod)#2 (2) { ["name"]=> string(11) "__construct" ["class"]=> string(15) "ReflectionClass" }