Posted: Fri Feb 03, 2006 4:14 pm
Though that is probably not the best implementation. I would separate the Registry and the Locator rather than having them all in one.Gambler wrote:Okay, now I get it. Thanks.
...
Gambler wrote:Does anyone know how to re-write my make() function without eval and reference loss?
Code: Select all
<?php
function & make($class, $args = array()){
include_once("dir/$class.php"); //or something like this
$argsCode = array();
foreach (array_keys($args) as $key) {
$argsCode[] = "\$args[$key]";
}
$code = "$obj =& new $class(" . join(', ', $argsCode) . ");";
eval($code);
return $obj;
}
?>