Dynamically Load Class and Access Static Variable in PHP <= 5.2 -
edit:
i solved getting of class variables using get_class_vars(), , acquired correct property array, if existed. seems simple enough me; if has different solution, i'd love hear (or read it, guess..) :)
i'm trying access static variable in dynamically-loaded class follows:
$file::$disabled
(in above statement, $file references name of class, , $disabled static variable want access within class.)
on php 5.3, works fine; result of running above code on lower versions, infamous t_paamayim_nekudotayim error.
how i've gotten around error when working older versions of php create getter function variable , return value call_user_func(). however, ease of use of developers adopting code, keep $disabled simple variable rather function.
i've tried eval() on statement, reach dead end.
does know how can make happen?
one option use reflection:
$rp = new reflectionproperty($file, $disabled); $value = $rp->getvalue();
or
$rc = new reflectionclass($file); $value $rc->getstaticpropertyvalue($disabled);
Comments
Post a Comment