命名空间可以在PHP中以数字开头吗? [英] Can a namespace start with a number in PHP?
本文介绍了命名空间可以在PHP中以数字开头吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
声明以下名称空间时:
<?php
namespace Example\3000;
我收到此错误:
Parse error: syntax error, unexpected '3000' (T_LNUMBER), expecting identifier (T_STRING) in [...]
所以我想知道PHP中的命名空间是否可以以数字开头?
So I wondered whether a namespace in PHP may start with a number?
推荐答案
否,一定不能.它必须以字母开头.
No, it must not. It must start with a letter.
我花了一段时间才在PHP的注释中找到了它.净.
It took me a while to find this in a comment on PHP.net.
使用数字,例如要进行版本控制,必须在字母前加上例如如下所示:
To use numbers e.g. for versioning it is necessary to prepend letters, e.g. like in the following:
<?php
namespace Example\V_3000;
这篇关于命名空间可以在PHP中以数字开头吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文