Stuff
public text v1 · immutable<?php
class pre_testclass {
function __construct($foo) {
echo $foo. ' ';
}
}
function instantiateObj($class, $args) {
$args = array_values($args);
$code = 'new $class($args[' . implode('], $args[', array_keys($args)) . ']);';
return eval($code);
}
$bar = 'testclass';
$foo = 'pre_'.$bar;
$$foo = instantiateObj($foo, array('hello'));
var_dump($pre_testclass);
// OUTPUT:
// hello NULL
?>