ReflectionClass::getProperty

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getPropertyクラスのプロパティを表す ReflectionProperty を取得する

説明

publicReflectionClass::getProperty(string$name): ReflectionProperty

クラスのプロパティを表す ReflectionProperty を取得します。

パラメータ

name

プロパティの名前。

戻り値

ReflectionProperty を返します。

例1 ReflectionClass::getProperty() の基本的な使用例

<?php
$class
= new ReflectionClass('ReflectionClass');
$property = $class->getProperty('name');
var_dump($property);
?>

上の例の出力は以下となります。

object(ReflectionProperty)#2 (2) { ["name"]=> string(4) "name" ["class"]=> string(15) "ReflectionClass" }

参考

To Top