本文整理匯總了PHP中AutoLoader::setIndexFilename方法的典型用法代碼示例。如果您正苦於以下問題:PHP AutoLoader::setIndexFilename方法的具體用法?PHP AutoLoader::setIndexFilename怎麽用?PHP AutoLoader::setIndexFilename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AutoLoader
的用法示例。
在下文中一共展示了AutoLoader::setIndexFilename方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: feng__autoload
/**
* Gets called, when an undefined class is being instanciated
*d
* @param_string $load_class_name
*/
function feng__autoload($load_class_name)
{
static $loader = null;
$class_name = strtoupper($load_class_name);
// Try to get this data from index...
if (isset($GLOBALS[AutoLoader::GLOBAL_VAR])) {
if (isset($GLOBALS[AutoLoader::GLOBAL_VAR][$class_name])) {
return include $GLOBALS[AutoLoader::GLOBAL_VAR][$class_name];
}
// if
}
// if
if (!$loader) {
$loader = new AutoLoader();
$loader->addDir(ROOT . '/application');
$loader->addDir(ROOT . '/environment');
$loader->addDir(ROOT . '/library');
$loader->setIndexFilename(ROOT . '/cache/autoloader.php');
}
// if
try {
$loader->loadClass($class_name);
} catch (Exception $e) {
try {
if (function_exists("__autoload")) {
__autoload($class_name);
}
} catch (Exception $ex) {
die('Caught Exception in AutoLoader: ' . $ex->__toString());
}
}
// try
}
示例2: feng__autoload
/**
* Gets called, when an undefined class is being instanciated
*d
* @param_string $load_class_name
*/
function feng__autoload($load_class_name) {
static $loader ;
//$loader = null;
$class_name = strtoupper($load_class_name);
// Try to get this data from index...
if(isset($GLOBALS[AutoLoader::GLOBAL_VAR])) {
if(isset($GLOBALS[AutoLoader::GLOBAL_VAR][$class_name])) {
return include $GLOBALS[AutoLoader::GLOBAL_VAR][$class_name];
} // if
} // if
//pre_print_r($loader) ;exit;
if(!$loader) {
$loader = new AutoLoader();
$loader->addDir(ROOT . '/application');
$loader->addDir(ROOT . '/environment');
$loader->addDir(ROOT . '/library');
//TODO Pepe: No tengo la conexion ni las clases de DB en este momento.. me conecto derecho
$temp_link = mysql_connect(DB_HOST, DB_USER, DB_PASS) ;
mysql_select_db(DB_NAME) ;
$res = mysql_query("SELECT name FROM ".TABLE_PREFIX."plugins WHERE is_installed = 1 AND is_activated = 1;");
while ($row = mysql_fetch_object($res)) {
$plugin_name = strtolower($row->name) ;
$dir = ROOT . '/plugins/'.$plugin_name.'/application' ;
if (is_dir($dir)) {
$loader->addDir($dir);
}
}
mysql_close($temp_link);
$loader->setIndexFilename(CACHE_DIR . '/autoloader.php');
} // if
try {
$loader->loadClass($class_name);
} catch(Exception $e) {
try {
if (function_exists("__autoload")) __autoload($class_name);
} catch(Exception $ex) {
die('Caught Exception in AutoLoader: ' . $ex->__toString());
}
} // try
} // __autoload