/ Published in: PHP
Gets the constants from a class using reflection.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class MyTestClass{ const TESTVAR1 = 1001; const TESTVAR2 = 1002; const TESTSTR1 = 'hello'; } $rc = new ReflectionClass('MyTestClass'); $v = $rc->getConstants(); //ksort($v);// sort by key foreach ( $v as $name => $value){ echo "$name => $value\n"; }