You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
841 B
32 lines
841 B
2 years ago
|
<?php
|
||
|
|
||
|
class Autoload{
|
||
|
private static $_instance = null;
|
||
|
|
||
|
public static function charger(){
|
||
|
if(null!==self::$_instance){
|
||
|
throw new RuntimeException(sprintf("%s is already started",__CLASS__));
|
||
|
}
|
||
|
|
||
|
self::$_instance=new self();
|
||
|
if(!spl_autoload_register(array(self::$_instance,'_autoload'),true)){
|
||
|
throw new RuntimeException(sprintf("%s : Could not start the autoload",__CLASS__));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static function _autoload($class){
|
||
|
global $rep;
|
||
|
$filename = $class.'.php';
|
||
|
$dir=array("./","config/","controler/");
|
||
|
|
||
|
foreach($dir as $d){
|
||
|
$file=$rep.$d.$filename;
|
||
|
// echo "<p>$file</p>";
|
||
|
if(file_exists($file)){
|
||
|
include $file;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
?>
|