
Originally Posted by
salbahis
quick question i havent tried this pa noon but possible ba to make a class dynamically and get functions and put in that dynamically created class..
example
PHP Code:
function testf(){
echo __FUNCTION__;
}
how can i dynamicaly create class and put
tesf in it... so far google is not being helpful...
I think OT ni siya. Anyway for the sake of answering your question. I don't think pwede nimo ma-dynamic ang pag create ug class except if mugamit ka ug eval. something like:
Code:
$str = 'class A { function testf() { echo __METHOD__; } }';
eval($str);
$class = 'A';
$obj = new $class();
$obj -> testf();
PHP's eval is a powerful and deadly function. it's one letter away from the word evil.