Accessing a CONST attribute of series of Classes
You can accomplish this without using eval
in pre-5.3 code. Just use the constant
function:
<?php
class MyClass
{
const CONSTANT = 'Const var';
}
$classname = 'MyClass';
echo constant("$classname::CONSTANT");
?>