PHP错误:Namespace declaration statement has to be the very first statement in the script

PHP错误:Namespace declaration statement has to be the very first statement in the script

原因:意思就是“namespace声明应写在第一行”。其实我们的代码是写在第一行的,原因就在于文本的格式!

解决方式:

方法一:该文件有BOM头问题,使用文本编辑器(比如UE),另存为UTF-8 时,选择无BOM头即可。

方法二:用系统建个纯txt文本,把名字(包括扩展名),如改成build.class.php代码内容复制过来,根本不用改变。保存。运行即可。