首頁  >  文章  >  後端開發  >  namespaces - php namespace在linux提示错误

namespaces - php namespace在linux提示错误

WBOY
WBOY原創
2016-06-06 20:16:571338瀏覽

Namespace declaration statement has to be the very first statement in the script

我在本地测试没问题了放上服务器就提示这个错误。

namespace common\modules\post\models;
use Yii;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
use common\modules\user\models\User;

namespace得是第一个语句我也没错呀,到linux下怎么报错了

回复内容:

Namespace declaration statement has to be the very first statement in the script

我在本地测试没问题了放上服务器就提示这个错误。

namespace common\modules\post\models;
use Yii;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
use common\modules\user\models\User;

namespace得是第一个语句我也没错呀,到linux下怎么报错了

编码问题,编码造成了在namesapce之前还有不可见但可被php识别的字符。是UTF-8编码的吗?如果是,要使用无bomUTF-8文件编码。

如楼上所说,utf8-无DOM(BOM)
windows下可以用notepad++方便查看编码.

楼上勾引我犯错

应该叫BOM吧

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn