开发者社区 问答 正文

php namespace在linux提示错误

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

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

<?php
namespace commonmodulespostmodels;
use Yii;
use yiidbActiveRecord;
use yiibehaviorsTimestampBehavior;
use commonmodulesusermodelsUser;

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

展开
收起
a123456678 2016-06-24 15:09:36 2157 分享 版权
1 条回答
写回答
取消 提交回答
  • 编码问题,编码造成了在namesapce之前还有不可见但可被php识别的字符。是UTF-8编码的吗?如果是,要使用无bom的UTF-8文件编码。

    2019-07-17 19:47:01
    赞同 展开评论