ReflectionClass::getProperty

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getProperty獲取類的一個屬性的 ReflectionProperty

說明

public ReflectionClass::getProperty(string $name): ReflectionProperty

獲取類的一個屬性的 ReflectionProperty。

參數(shù)

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"
}

參見