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

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -