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
Post a Comment