dongpeiwei8589 2016-11-01 22:50
浏览 34
已采纳

PHP命名空间奇怪文件夹,以“t”,“s”,“n”结尾

I am having an intersting issue where if one of the folders in the namespace ends in a "t", "s", or "n" then has a subfolder after it then it wont parse.

EX:

namespace DDM\Components\Widget\List;

This causes: Parse error: syntax error, unexpected 'List' (T_LIST), expecting identifier (T_STRING) in <...filepath...>

Same happens for folder ending with the other 2 letters previously mentioned.

I am on a windows system but the files are being served from a Debian (jessie) box, running PHP Version 5.6.27-0+deb8u1 through nginx and PHP-FPM

Update

If I try prefixing the entire namespace with a \ then phpstorm no longer recognizes it as a syntax error but the php compiler still gives the same error as above.

Any "L" name subfolder has this result

As pointed out by Jay List is a PHP reserved word, however using any "L" folder name results in a different error:

Fatal error: Undefined constant 'DDM\Components\Widget\Lists' 

Any suggestions are appreciated.

  • 写回答

1条回答 默认 最新

  • dsgs8208 2016-11-01 22:58
    关注

    This is because List is a reserved keyword and reserved keywords are not allowed, even in namespaces.

    PHP Reserved Keywords

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建