ReflectionClass::getStaticPropertyValue

(PHP 5 >= 5.1.2, PHP 7)

ReflectionClass::getStaticPropertyValueGets static property value

Description

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

Gets the value of a static property on this class.

Parameters

name

The name of the static property for which to return a value.

def_value

A default value to return in case the class does not declare a static property with the given name. If the property does not exist and this argument is omitted, a ReflectionException is thrown.

Return Values

The value of the static property.

Examples

Example #1 Basic usage of ReflectionClass::getStaticPropertyValue()

<?php
class Apple {
    public static $color = 'Red';
}

$class = new ReflectionClass('Apple');
var_dump($class->getStaticPropertyValue('color'));
?>

The above example will output:

string(3) "Red"

See Also

© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/reflectionclass.getstaticpropertyvalue.php