php - PHP 命名空间名称中的有效字符是什么?

标签 php

我的命名空间名称必须遵循哪些规则?

最佳答案

Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*

http://php.net/manual/en/language.variables.basics.php

这里的“其他标签”确实指的是 namespace 以及类和函数名称等其他内容。

请注意,PHP 对编码没有 native 理解,并将此类标签视为纯粹的字节数组;大多数 Unicode 字符串(读取:UTF-8)将满足上述朴素的正则表达式:

// yup, works
namespace 漢字;
class 文字 {}

关于php - PHP 命名空间名称中的有效字符是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41027816/

相关文章:

javascript - 从跨度到输入的值

php - 在另一个表的基础上填充mysql表

php - 在连接查询中根据表名区分记录

php - 使用 Kohana 的数据库库绑定(bind)参数

php - socket_write(): unable to write to socket [10053]

php - 如何在 PHP 中使用 HTTP 缓存 header

php - 如果你分解一个字符串并且说字符串不包含分隔符,那么分解会引发错误吗?

php - SQL 验证!

javascript - ajax POST 在 ajax 成功中没有做任何事情

php - WordPress php在if语句中读取数据库