Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP不能自动加载类_Php_Url Routing_Autoload - Fatal编程技术网

PHP不能自动加载类

PHP不能自动加载类,php,url-routing,autoload,Php,Url Routing,Autoload,我在index.php中保存了从lib文件夹加载类的_autoload()函数 function __autoload($class) { if(file_exists(LIBS . $class .".php")){ require LIBS . $class .".php"; } } 我有一门仪表板课 class Dashboard extends Controller { public function __construc

我在index.php中保存了从lib文件夹加载类的_autoload()函数

 function __autoload($class) {
      if(file_exists(LIBS . $class .".php")){
           require LIBS . $class .".php";
      }
 }
我有一门仪表板课

 class Dashboard extends Controller {
      public function __construct(){
           Auth::handleLogin();
      }
 }
在Ubuntu12.04上使用sudo apt get安装php5和apache2,我无法自动加载该验证,可能会出现什么问题?它在我的另一台使用Bitnami XAMPP服务器的计算机上工作

这是我得到的错误:

 Fatal error: Class 'Auth' not found in /var/www/app/controllers/dashboard.php on line 6

其中Auth::handleLogin();正在被调用。

我有linux mint 16,我在进行对象声明时将其与名称空间一起使用 这是完美的工作

spl_autoload_register(function ($class) {

    $class = str_replace("\\", "/", $class);

    include $class . '.php';

});
在索引文件中

require_once 'autoload.php';

$db = new DBWork\DBWork('localhost', 'northwind', 'root', '123');

您之所以会遇到这种情况,是因为在linux中,文件系统路径区分大小写。

var_dump(LIBS.$class.“.php”,getcwd())什么也没发生。。如果我死了(“进入函数”)它进入函数..你把它放在哪里了<代码>变量转储
在这种情况下应输出2个值。如果没有-您犯了错误。string(38)“/var/www/rcs/app/backend/libs/Auth.php”string(24)“/var/www/rcs/app/backend”致命错误:在第6So行的/var/www/rcs/app/backend/app/controllers/dashboard.php中找不到类“Auth”?
/var/www/rcs/app/backend/libs/Auth.php
文件是否存在?别忘了它也应该跟在字母大写后面。