ReflectionClass::getReflectionConstants

(PHP 7 >= 7.1.0, PHP 8)

ReflectionClass::getReflectionConstantsSınıf sabitlerini döndürür

Açıklama

publicReflectionClass::getReflectionConstants(?int$filter = null): array

Yansıtılan sabitleri döndürür.

Bağımsız Değişkenler

filter

Seçimlik düzgeç. İstenen sabitin görünürlüklerini süzmek için. ReflectionClassConstant sabitleri kullanılarak yapılandırılır ve tüm sabit görünürlükleri öntanımlanır.

Dönen Değerler

ReflectionClassConstant nesnelerini içeren bir dizi döner.

Sürüm Bilgisi

Sürüm: Açıklama
8.0.0filter eklendi.

Örnekler

Örnek 1 - Temel ReflectionClass::getReflectionConstants() örneği

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

$foo = new Foo();

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

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

var_dump($consts);

?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

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

Ayrıca Bakınız

To Top