Evi*_*kie 11 php namespaces autoload
我有以下PHP代码:
的index.php
<?php
spl_autoload_extensions(".php");
spl_autoload_register();
use modules\standard as std;
$handler = new std\handler();
$handler->delegate();
?>
Run Code Online (Sandbox Code Playgroud)
模块\标准\ handler.php
<?php
namespace modules\standard {
class handler {
function delegate(){
echo 'Hello from delegation!';
}
}
}
?>
Run Code Online (Sandbox Code Playgroud)
在运行WAMP的Windows 7下,代码生成消息"Hello from Delegation!" 但是在Linux下,我得到以下内容:
致命错误:spl_autoload():无法在第15行的/var/www/index.php中加载类modules\standard\handler
Windows在WAMP下运行PHP 5.3.0,Linux在Ubuntu 9.10下运行5.3.2 dotdeb软件包.
这是我的linux机箱上的配置问题,还是在不同操作系统上处理命名空间和自动加载的方式不同