获得php类包含的所有元素以key-value的形式输出
class MyTestClass{ const TESTVAR1 = 1001; const TESTVAR2 = 1002; const TESTSTR1 = 'hello'; } $rc = new ReflectionClass('MyTestClass'); $v = $rc->getConstants(); asort($v);// sort by value //ksort($v);// sort by key foreach ( $v as $name => $value){ echo "$name => $value\n"; }