Php/docs/reflectionclass.getstaticpropertyvalue

提供:Dev Guides
< Php
移動先:案内検索

ReflectionClass::getStaticPropertyValue

(PHP 5 >= 5.1.2, PHP 7)

ReflectionClass::getStaticPropertyValue静的なプロパティの値を取得する


説明

public ReflectionClass::getStaticPropertyValue ( string $name [, mixed &$def_value ] ) : mixed

このクラスの静的なプロパティの値を取得します。


パラメータ

name
値を返したい静的プロパティの名前。
def_value
指定した名前の静的プロパティがそのクラスに存在しない場合に返す、デフォルト値。 プロパティが存在せず、かつこの引数も省略されていた場合は、 ReflectionException が発生します。


返り値

静的プロパティの値を返します。


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

<?phpclass Apple {    public static $color = 'Red';}$class = new ReflectionClass('Apple');var_dump($class->getStaticPropertyValue('color'));?>

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


string(3) "Red"

参考