Php 包含自动加载程序时出现HTML错误500

Php 包含自动加载程序时出现HTML错误500,php,spl-autoloader,Php,Spl Autoloader,这是我的密码。 Index.php define('_PATH', __DIR__ . '/'); require_once('libs/classloader.php'); echo 'test'; Classloader.php function ClassLoader($className) { if(file_exists(__DIR__ '/class.'. strtolower($className) . '.php')) { require_onc

这是我的密码。 Index.php

define('_PATH', __DIR__ . '/');
require_once('libs/classloader.php');
echo 'test';
Classloader.php

function ClassLoader($className)
  {
    if(file_exists(__DIR__ '/class.'. strtolower($className) . '.php'))
    {
      require_once(__DIR__ '/class.'. strtolower($className) . '.php');
    }
    else {
      echo 'ERROR: '. $className;
    }
  }

  spl_autoload_register('ClassLoader');

我在浏览器中只看到错误500。PHP版本是5.4,服务器是LiteSpeed。

我认为这一小改动应该有帮助:

function ClassLoader($className)
{
    if(file_exists(__DIR__ .'/class.'. strtolower($className) . '.php'))
    //if(file_exists(__DIR__ '/class.'. strtolower($className) . '.php'))
    {
      require_once(__DIR__ .'/class.'. strtolower($className) . '.php');
      //require_once(__DIR__ '/class.'. strtolower($className) . '.php');
    }
    else {
      echo 'ERROR: '. $className;
    }
}

spl_autoload_register('ClassLoader');

500
表示内部服务器错误。我相信LiteSpeed也有错误日志,您可以查看。您的PHP错误日志报告了什么?谢谢。我注意到它没有在页面(和日志)上显示错误,它只显示错误500。如何修复它?display_errors已打开并使用函数error_reporting()。我使用xdebug扩展sudo apt get install php5 xdebug。它显示完整的堆栈跟踪,您也可以查看此链接以了解如何启用启动错误。