PHP 5.6.0 released

提示

要写出能经受住时间考验的代码,建议给任何进入全局命名空间的符号都加上一个不常见的 3-4 字母的前缀(或后缀),中间用下划线分开。为了避免与其它用户空间代码出现命名空间冲突,建议先研究一下其它项目中已有的前缀(或后缀)并适当地公布出来。示例如下:

  • MyPx_someFunc()

  • Foo_Date

  • $asdf_dbh

add a note add a note

User Contributed Notes 3 notes

up
12
willian at gt44 dot com
1 year ago
I don't think it makes sense nowadays. We have namespaces now!
up
1
kanone at rogers dot com
2 months ago
The javascript community has developed a strong cultural bias against adding anything to the global namespace.  (See e.g. Addy Osmani's article on Essential JavaScript Namespacing Patterns .)  Namespaces have been available in JS for many years and are ubiquitous.  There is also a great deal of freely available tutorial material for the interested reader.
up
0
earnie at users dot sourceforge dot net
7 months ago
@willian at gt44 dot com: What about clashes of the namespace?  It is still good advice to check for previously used names before assigning anything to the global namespace.
To Top