0
错误:命名空间误差ZF2
Fatal error: Namespace declaration statement has to be the very first statement in the script in C:\xampp\htdocs\zf2-tutorial\module\Album\Module.php on line 8
Module.php
<?php
namespace Application;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
class Module
{
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
}
我已经检查了空格,正如你所看到的命名空间声明后的第一个打开php标签。无法弄清楚是什么原因造成的。
我会尝试unicode的东西,看看这是否修复它,在我目前的IDE我检查了空格。 – Tiberiu 2014-11-23 11:54:42
我用UTF8保存了它,没有BOM,它仍然输出这个错误。唯一发生变化的是出现错误的行(第3行) – Tiberiu 2014-11-23 12:05:03
您是否使用Windows?你在用什么IDE?输出可以在包含Module类的另一个文件中。 – Falc 2014-11-23 12:06:11