命名空间可以在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;