我无法使用autoload在debian下运行一个php项目。我的项目是这样的:
myproject
- config
autoload.php
- src
- Project
router.php
index.php
autoload.php:
<?php
// Your custom class dir
define('SRC_DIR', './src/');
// Add your class dir to include path
set_include_path(SRC_DIR);
// You can use this trick to make autoloader look for commonly used "My.class.php" type filenames
spl_autoload_extensions('.php');
// Use default autoload implementation
spl_autoload_register();
?>
index.php:
<?php
// Chargement des classes via le namespace
require_once('./config/autoload.php');
$router = new \Project\Router();
router.php:
<?php
namespace Project;
class Router {
当我尝试去index.php时,我有这个错误:
PHP致命错误:spl_autoload():类Project \ Router不能 加载到/var/www/html/exophp/index.php
有什么想法吗?
由于
答案 0 :(得分:0)
问题是目录&#34;项目&#34;它必须被称为&#34;项目&#34;。它运作后!