php - Access Abstract Class Property dynamically (the Class) -


this question has answer here:

given there abstract classes , want access properties different classes , want user interface user might enter class , property.

is there better way than

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

if class known (or 1 class exists), use

$_val = classname::$$_prop; 

but how replace classname?

may find power of magic constants , relize error of using eval() (should pronounced "evil")


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

Error while updating a record in APEX screen -

c++ - In an add-in in Excel, written in C(++), how does one get the name of the function which called into the addin? -