Forum Moderators: coopster
Best of luck!
[uk2.php.net...]
$toRun = "\$module = new Mod_{$toPass} ();";
eval ($toRun);
Eval() should not be used in situations like this. Unless a lot of pre-checking of variables is done, eval() leads to security flaws in PHP scripts and the possibility of your PHP script getting hacked.
Only in rare cases should eval be used, and I have avoid these cases as much as possible. Eval() is evil.
Instead, what I do is:
class Mod_Test {
function Mod_Test () {
echo "Running<br>";
}
function test2 () {
echo "Running2<br>";
}
}
$toPass = 'Test';
$classToLoad = 'Mod_' . $toPass;
$module = new $classToLoad();
$module -> test2 ();