ねえ、私は助言が必要です。この小さな機能は私が「良い」と書いたのか、それともリソース豚になるのだろうか?それは、次のように使われています :潜在的なPHPメモリの豚かどうか?
$login = load_class('LoginClass');
または
load_class('LoginClassTwo', false); // for singletons and stuff
$loginTwo = LoginClassTwo::getInstance();
は、ここで私はこの方法が効果的でないことを心配し、あまりにも多くのメモリを消費するために起こっている機能
function load_class($class, $instantiate = TRUE){
static $obj = array(); // holds the instancec of the classes
$l = strtolower($class); // the name of the file is the name of the class but lowercased
if (isSet($obj[$l])) { // Do we have an instance?
return $obj[$l];
}
$file = 'classess/' . $l . '.class.php';
if (file_exists($file) && is_readable($file)) { // Can we read the file?
include $file;
if ($instantiate == FALSE) { // Do we need to instantiate?
$obj[$l] = TRUE;
} else {
$obj[$l] = new $class;
}
return $obj[$l];
}
return FALSE; }
ですまたは私は間違っていますか?これにはより良い方法がありますか?
コード自体が漏洩することはない、そのような可能性がある場合、私は聞いてるのよ;情報について) – Pockata