本文整理汇总了PHP中Autoload::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Autoload::run方法的具体用法?PHP Autoload::run怎么用?PHP Autoload::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autoload
的用法示例。
在下文中一共展示了Autoload::run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
if (!is_array($folder)) {
throw new \Exception('no es un array');
}
$this->add($folder);
}
protected function add($folder)
{
foreach ($folder as $load) {
$this->folder[] = $load;
}
}
protected function loader($classname)
{
$filename = $classname;
foreach ($this->folder as $add) {
$test = $add . str_replace("\\", "/", $filename) . '.php';
if (file_exists($test)) {
include $test;
} else {
unset($test);
}
}
}
public function run()
{
spl_autoload_register(array($this, 'loader'));
}
}
$load = new Autoload([APP_PATH . '/src/', APP_PATH . '/app/', APP_PATH . '/Database/']);
$load->run();
示例2: run
<?php
include '__FOOLPHP_TOOLS__ROOT__/config.php';
$obj = new Autoload();
for ($i = 0; $i < 10; $i++) {
$r = $obj->run($application_path, $config_path, $scan_dir);
if (true === $r) {
break;
}
}
class Autoload
{
private $filter = array('views');
private $map_value_name = '$fool_php_class_map';
public function run($app_root, $config_root, $scan_dir)
{
/*{{{*/
$list = array();
foreach ($scan_dir as $_dir) {
$_list = $this->scanFile($app_root . '/' . $_dir);
if (empty($_list)) {
continue;
}
$list = array_merge($list, $_list);
}
$tpl = "\t'%s' => '%s',\n";
$content_tpl = "<?php\n/*create by : " . $_SERVER['LOGNAME'] . " on : %s*/\n%s = array(\n%s);\n";
$d = "";
$n = 1;
foreach ($list as $class_name => $path) {
$d .= sprintf($tpl, $class_name, $path);