Namespace declaration statement has to be the very first statement or after any declare call in the script

0x00缘起

代码部署在windows上,出现了一个bug,临时用记事本打开修改了一下,于是出现了500错误

0x01排错

查看log,提示如下
“Namespace declaration statement has to be the very first statement or after any declare call in the script xxx.controller”。于是看这个php文件,什么也没发现。
一头雾水,只好在网上找了一下,没想到是万恶的bom引起的。

0x03解决办法

重新保存为utf-8无bom格式。

原文地址:https://www.cnblogs.com/xdao/p/php_bom.html