ReflectionClass::getParentClass
ReflectionClass::getProperty
ReflectionClass
PHP Manual

# ReflectionClass::getProperties

(PHP 5)

ReflectionClass::getProperties — Gets properties

### Beschreibung

public array ReflectionClass::getProperties ([ int `$filter` ] )

Retrieves reflected properties.

### Parameter-Liste

`filter`

  The optional filter, for filtering desired property types. It's configured using the ReflectionProperty constants, and defaults to all property types.

### Rückgabewerte

An array of ReflectionProperty objects.

### Beispiele

Beispiel #1 ReflectionClass::getProperties() filtering example

This example demonstrates usage of the optional `filter` parameter, where it essentially skips private properties.

`<?php
class Foo {
public $foo = 1;
protected $bar = 2;
private $baz = 3;
}
$foo = new Foo();
$reflect = new ReflectionClass($foo);
$props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED);
foreach ($props as $prop) {
print $prop->getName() . "\n";
}
var_dump($props);
?>`

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

    foo
    bar
    array(2) {
      [0]=>
      object(ReflectionProperty)#3 (2) {
        ["name"]=>
        string(3) "foo"
        ["class"]=>
        string(3) "Foo"
      }
      [1]=>
      object(ReflectionProperty)#4 (2) {
        ["name"]=>
        string(3) "bar"
        ["class"]=>
        string(3) "Foo"
      }
    }

### Siehe auch

- ReflectionClass::getProperty - Gets property
- ReflectionProperty
- ReflectionProperty constants

ReflectionClass::getParentClass
ReflectionClass::getProperty
ReflectionClass
PHP Manual