ReflectionClass::getProperty

(PHP 5)

ReflectionClass::getPropertyВозвращает экземпляр ReflectionProperty для свойства класса

Описание

public ReflectionProperty ReflectionClass::getProperty ( string $name )

Возвращает экземпляр 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"
}

Смотрите также

Коментарии

If the class doesn't have a property with the given name, a ReflectionException will be raised.
2011-08-02 18:38:00
http://php5.kiev.ua/manual/ru/reflectionclass.getproperty.html
Автор:
Accessing private properties is possible, but care must be taken if that private property was defined lower into the inheritance chain. For example, if class A extends class B, and class B defines a private property called 'foo', getProperty will throw a ReflectionException.

Instead, you can loop over getParentClass until it returns false to look for the private property, at which point you can access and/or modify its value as needed.
2015-06-16 07:16:00
http://php5.kiev.ua/manual/ru/reflectionclass.getproperty.html

    Поддержать сайт на родительском проекте КГБ