1--TEST-- 2ReflectionClass::getConstants() 3--FILE-- 4<?php 5class C { 6 const a = 'hello from C'; 7} 8class D extends C { 9} 10class E extends D { 11} 12class F extends E { 13 const a = 'hello from F'; 14} 15class X { 16} 17 18$classes = array('C', 'D', 'E', 'F', 'X'); 19foreach($classes as $class) { 20 echo "Constants from class $class: \n"; 21 $rc = new ReflectionClass($class); 22 var_dump($rc->getConstants()); 23} 24?> 25--EXPECTF-- 26Constants from class C: 27array(1) { 28 ["a"]=> 29 string(12) "hello from C" 30} 31Constants from class D: 32array(1) { 33 ["a"]=> 34 string(12) "hello from C" 35} 36Constants from class E: 37array(1) { 38 ["a"]=> 39 string(12) "hello from C" 40} 41Constants from class F: 42array(1) { 43 ["a"]=> 44 string(12) "hello from F" 45} 46Constants from class X: 47array(0) { 48} 49