function __autoload($className){ //如果是其他类,将类名转为小写 include strtolower($className).".class.php"; }
但一般情况下,在这之前我们需要用 get_include_path() 和 set_include_path() 方法设置include包含文件所在的目录
$include_path=get_include_path(); $include_path.=PATH_SEPARATOR.OURCLASSPATH."/"; set_include_path($include_path);
其中 PATH_SEPARATOR 分隔符号 Linux(:) Windows(;)