本文整理匯總了PHP中Autoload::initialize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Autoload::initialize方法的具體用法?PHP Autoload::initialize怎麽用?PHP Autoload::initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Autoload
的用法示例。
在下文中一共展示了Autoload::initialize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __autoload
function __autoload($class)
{
Autoload::initialize();
$class = strtolower($class);
$class = strtr($class, '\\_', '/.');
if (strpos($class, 'apps/') === 0) {
if (is_file($class . '.php')) {
return require_once $class . '.php';
} else {
$class = substr($class, 4);
foreach (Autoload::paths() as $path) {
$file = $path . $class . '.php';
if (!is_file($file)) {
continue;
}
return require_once $file;
}
}
} else {
if (is_file($class . '.php')) {
return require_once $class . '.php';
}
}
require_once $class . '.php';
}
示例2: die
if (file_exists($path . DIRECTORY_SEPARATOR . $file)) {
require $path . DIRECTORY_SEPARATOR . $file;
if (!class_exists($class, false) && !interface_exists($class, false)) {
die(new \Exception('Class ' . $class . ' was not present in ' . $path . DIRECTORY_SEPARATOR . $file . '") [PEAR2_Autoload-0.2.3]'));
}
return true;
}
}
$e = new \Exception('Class ' . $class . ' could not be loaded from ' . $file . ', file does not exist (registered paths="' . implode(PATH_SEPARATOR, self::$paths) . '") [PEAR2_Autoload-0.2.3]');
$trace = $e->getTrace();
if (isset($trace[2]) && isset($trace[2]['function']) && in_array($trace[2]['function'], array('class_exists', 'interface_exists'))) {
return false;
}
if (isset($trace[1]) && isset($trace[1]['function']) && in_array($trace[1]['function'], array('class_exists', 'interface_exists'))) {
return false;
}
die((string) $e);
}
/**
* return the array of paths PEAR2 autoload has registered
*
* @return array
*/
static function getPaths()
{
return self::$paths;
}
}
}
Autoload::initialize(dirname(__DIR__));
示例3: microtime
<?php
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
require 'core/config/config.php';
require 'app/config/config.php';
Autoload::initialize();
$session = Session::getInstance();
$session->set('start', $start);
Router::dispatch();