本文整理汇总了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();