このコードは機能します$vars
が、関数で定義できませんcall()
。$vars
に渡せないのはなぜarray_walk_recursive()
ですか?
class lib{
private $library;
function __construct($lib="")
{
$this->library = $lib;
}
function set($vars)
{
$decoded_classes = json_decode($this->library,true);
array_walk_recursive($decoded_classes,function(&$f) {$f = create_function($vars,$f);});
return $decoded_classes;
}
}
$json = '
{
"class1": {
"function1":"return \"$a<b>$b</b>!\";"
},
"class2": {
"function2":"return $b;",
"function3":"return $c;"
},
"function1":"return \"test\";"
}';
$lib = new lib($json);
$lib = $lib->set("$a,$b");
$lib = $lib["class1"]["function1"]("asdasasd","asdasasd");
echo $lib;