概要
PHPクラスに定義された、定数constを配列でまとめて取得する方法をご紹介します。
ReflectionClassクラスのgetConstantsメソッドを使う。
◯ ReflectionClassクラス
ReflectionClassクラスは、クラスについての情報を報告する。
http://php.net/manual/ja/class.reflectionclass.php
◯ getConstantsメソッド
ReflectionClassクラスのgetConstantsメソッドを使うと、クラスで定義されているすべての定数を取得する。
http://php.net/manual/ja/reflectionclass.getconstants.php
利用例
const.php
class Const {
    // 定数
    const A_FIELD = 'field_5bf4bc485e0c8';
    const B_FIELD = 'field_5bf4bd085e0c9';
    const C_FIELD = 'field_5bf4bd685e0ca';
    const D_FIELD = 'field_5bf4bde15e0cb';
    const E_FIELD = 'field_5c00cc69cf869';
    //定数を配列で取得する
    public static function getConstants() {
        $oClass = new ReflectionClass( __CLASS__ );
        return $oClass->getConstants();
    }
}
index.php
$consts = Const::getConstants();
foreach ( $consts as $key => $value ) {
        echo '定数の名前 : ' . $key;
        echo '定数の値 : ' . $value;
}
これで、大量の「定数const」を呼び出すのも楽になります。