(PHP 5, PHP 7, PHP 8)
ReflectionClass::getConstructor — 獲取類(lèi)的構(gòu)造函數(shù)
此函數(shù)沒(méi)有參數(shù)。
一個(gè) ReflectionMethod 對(duì)象,反射了類(lèi)的構(gòu)造函數(shù),或者當(dāng)類(lèi)不存在構(gòu)造函數(shù)時(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" }