PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

ReflectionClass::getReflectionConstants - Gets class constants | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

ReflectionClass::getReflectionConstants

(PHP 7 >= 7.1.0)

ReflectionClass::getReflectionConstantsGets class constants

説明

public array ReflectionClass::getReflectionConstants ( void )

Retrieves reflected constants.

パラメータ

この関数にはパラメータはありません。

返り値

An array of ReflectionClassConstant objects.

例1 Basic ReflectionClass::getReflectionConstants() 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->getReflectionConstants();

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

var_dump($consts);

?>

上の例の出力は、 たとえば以下のようになります。

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

参考


忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「ReflectionClass::getReflectionConstants - Gets class constants」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | ReflectionClass::getReflectionConstants - Gets class constants」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: