php laravel 错误:命名空间声明语句必须是第一个语句或在脚本中的任何声明调用之后
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46335319/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
laravel error : Namespace declaration statement has to be the very first statement or after any declare call in the script
提问by Kenneth
After I pull my project in git. I get this error. Its my 1st time to encounter this error.
在我将项目拉入 git 之后。我收到这个错误。这是我第一次遇到这个错误。
the error is:
错误是:
Namespace declaration statement has to be the very first statement or after any declare call in the script
my Model
我的模特
<?php
namespace App\Models;
the version of my laravel is 5.5. any idea?
我的 Laravel 版本是 5.5。任何的想法?
回答by Gayan
There is an empty space before the <?php
tag. Remove it.
<?php
标签前有一个空格。去掉它。
<?php
namespace App\Models;
回答by veyselsahin
If problem continue you have to remove bom from file via notepad++
如果问题仍然存在,您必须通过记事本++从文件中删除 bom
回答by ShirleyCC
回答by Lekia
In some cases, it may be that you're looking at the wrong. Especially in Laravel/Laravel testing, if you move, copy or rename a file. Possibilities are it could be pointing to the old file.
在某些情况下,您可能看错了。特别是在 Laravel/Laravel 测试中,如果您移动、复制或重命名文件。有可能它指向旧文件。