d-_*_*_-b 20 php standards pear comments
我(最后)已经阅读了PEAR(php)编码标准.
这样评论的目的是什么:
/**
* Here is my comment
* I Wrote this in a haiku
* But why put the stars?
*/
Run Code Online (Sandbox Code Playgroud)
与此相反:
/*
Here is a comment
No haiku or
anything special, but it still works!
*/
Run Code Online (Sandbox Code Playgroud)
Ja͢*_*͢ck 16
该/** stuff */
文档也称为DocBlock表示法.
它用于记录PHP函数,类等.
/**
* A test function
*
* @param foo $bar
* @return baz
*/
function test(foo $bar) { return new baz; }
Run Code Online (Sandbox Code Playgroud)
一些编辑很好地利用它来执行他们的Code Insight功能,这是一个非常强大的工具,可以减少您花在查看旧函数声明上的时间.Aptana和Zend Studio有这个功能,也可能是其他功能.
您还可以将它与Reflection结合使用来执行某种AOP,在声明之上对DocBlock进行运行时检查.实际上,Doctrine使用它为它们的"Active Record"实现构建一个对象属性映射.