-
- /**
- * Automatically load related class library files
- */
- function __autoload($classname){
- if(substr($classname,-6)=="Action"){
- include APP_PATH.'controllers /'.$classname.'.class.php';
- }elseif(substr($classname, -5)=="Model"){
- include APP_PATH.'models/'.$classname.'.class.php' ;
- }elseif($classname=="Smarty"){
- include SYSTEM_PATH.'smarty/Smarty.class.php';
- }else{
- include APP_PATH.'common/'.$classname.'.class.php' ;
- }
- }
- ?>
-
Copy code
Another way to include the path:
-
- function __autoload($class_name) {
- $path = str_replace('_', DIRECTORY_SEPARATOR, $class_name);
- require_once $path.'.php';
- }
- ?>
-
Copy code
Instructions: Convert the underscore to the directory separator (DIRECTORY_SEPARATOR). This can effectively manage library files and solve cross-platform problems.
|