0

Given there are Abstract Classes and I want to access certain properties from different classes and I want a user Interface that the user might enter the class and the property.

Is there any better way than

$_class = "CLASSNAME";
$_prop  = "FILE";

$_eval = "return (" . $_class . "::$" . $_prop . ");"; 
$_val = eval( $_eval );

If the Class will be known (or only one class exists), I could use

$_val = CLASSNAME::$$_prop;

But how to replace CLASSNAME?

jwka
  • 115
  • 7

1 Answers1

-1

May you find the power of Magic Constants and relize the error of using eval() (should be pronounced like "evil")

Community
  • 1
  • 1