= 5.1.2, PHP 7, PHP 8)ReflectionClass::getStaticPropertyValue — 獲取靜態(tài)(static)屬性的值說明public ReflectionClas">

ReflectionClass::getStaticPropertyValue

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

ReflectionClass::getStaticPropertyValue獲取靜態(tài)(static)屬性的值

說明

public ReflectionClass::getStaticPropertyValue(string $name, mixed &$def_value = ?): mixed

獲取這個類里靜態(tài)(static)屬性的值。

參數(shù)

name

靜態(tài)屬性的名稱,來返回它的值。

def_value

假如類沒有定義 name 的 static 屬性,將返回一個默認(rèn)值。 如果屬性不存在,并且省略了此參數(shù),將會拋出 ReflectionException 。

返回值

靜態(tài)屬性的值。

范例

示例 #1 ReflectionClass::getStaticPropertyValue() 的基本用法

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

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

以上例程會輸出:

string(3) "Red"

參見