本文整理汇总了PHP中AutoLoader::addDir方法的典型用法代码示例。如果您正苦于以下问题:PHP AutoLoader::addDir方法的具体用法?PHP AutoLoader::addDir怎么用?PHP AutoLoader::addDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoLoader
的用法示例。
在下文中一共展示了AutoLoader::addDir方法的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