<?php
    function __autoload( $class_name) {
         require_once $class_name.'.php';}
$obj=new SubClass();
?>
Warning: require_once(BaseClass.php) [function.require-once]: failed to open stream: No such file or directory in D:\www\test\run.php on line 3Fatal error: require_once() [function.require]: Failed opening required 'BaseClass.php' (include_path='.;C:\php5\pear') in D:\www\test\run.php on line 3为什么这样呢

解决方案 »

  1.   

    当然不行的,要用绝对地址的。
    被引入的文件里面如果有引入其他文件的,那么必须写绝对路径,否则会出错。./a.php
    ./include/b.php
    ./c.php./a.php 引入 ./include/b.php,而./include/b.php里面又引入了./c.php,那么,如果直接在 ./include/b.php里面写 include './c.php'; 可能会导致错误,应该写 include dirname(dirname(__FILE__)).'./c.php'才不会~~~~~~