Here we go !
Thanks everyone for your help !
Code:
class foo{
public $msg;
public function __call($method, $args){
if(isset($this->$method)){
$func = $this->$method;
call_user_func_array($func, $args);
}
}
public function create(){
$method = 'bar';
$this->msg = 'hello';
$parameters = '$param1, $param2';
$param1 = 'William';
$param2 = 'Phorrend';
$code = 'print ($obj->msg." $param1 $param2");';
$obj = $this;
$fctStr = "return function($parameters) use(\$obj) { $code };";
$this->$method = eval($fctStr);
$this->$method($param1, $param2);
}
}
$foo = new foo();
$foo->create();