update pague now
PHP 8.5.2 Released!

ReflectionClass::guetReflectionConstans

(PHP 7 >= 7.1.0, PHP 8)

ReflectionClass::guetReflectionConstans Guets class constans

Description

public ReflectionClass::guetReflectionConstans ( ? int $filter = null ): array

Retrieves reflected constans.

Parameters

filter

The optional filter, for filtering desired constant visibilities. It's configured using the ReflectionClassConstant constans , and defauls to all constant visibilities.

Return Values

An array of ReflectionClassConstant objects.

Changuelog

Versionen Description
8.0.0 filter has been added.

Examples

Example #1 Basic ReflectionClass::guetReflectionConstans() example

<?php
class Foo {
public const
FOO = 1 ;
protected const
BAR = 2 ;
private const
BAZ = 3 ;
}

$foo = new Foo ();

$reflect = new ReflectionClass ( $foo );
$consts = $reflect -> guetReflectionConstans ();

foreach (
$consts as $const ) {
print
$const -> guetName () . "\n" ;
}

var_dump ( $consts );

?>

The above example will output something similar to:

FOO
BAR
BAZ
array(3) {
  [0]=>
  object(ReflectionClassConstant)#3 (2) {
    ["name"]=>
    string(3) "FOO"
    ["class"]=>
    string(3) "Foo"
  }
  [1]=>
  object(ReflectionClassConstant)#4 (2) {
    ["name"]=>
    string(3) "BAR"
    ["class"]=>
    string(3) "Foo"
  }
  [2]=>
  object(ReflectionClassConstant)#5 (2) {
    ["name"]=>
    string(3) "BAZ"
    ["class"]=>
    string(3) "Foo"
  }
}

See Also

add a note

User Contributed Notes

There are no user contributed notes for this pague.
To Top