Home >Backend Development >PHP Tutorial >Comment tags that every PHPer should master!
Recommended: "PHP Video Tutorial"
Comment tags play a very important role in code comments Large and good annotation tags can give you a better and more comfortable experience in the programming process, so today I am going to sort out these tags and display them in the form of pictures and texts. On the one hand, it is to help myself understand these annotation tags. A summary. On the other hand, I also hope that everyone can better understand the comment tags
Everyone hopes to write beautiful code. Maybe you are only one tag away from beautiful code
Tag | Use | Description |
---|---|---|
@abstract | Variables and methods of abstract classes | |
@access | public , private or protected | Access and usage rights of the document. @access private indicates that the document is protected. |
@author | 张三zhangsan@163.com | Document author |
@copyright | Name time | Document copyright information |
@deprecated | version | Deprecated method in the document |
@deprec | Same as @deprecated | |
@example | /path/to/example | The location of the example file saved externally to the document. |
@exception | For exceptions thrown by methods in the document, you can also refer to @throws. | |
@global | Type: $globalvarname | Global variables and related methods and functions in the document |
@ignore | Ignore keywords specified in the document | |
@internal | Development Team internal information | |
#@link | URL | Similar to license but you can also find more detailed information in the document through the link |
@name | Variable alias | Specify an alias for a variable |
@magic | phpdoc.de compatibility | |
@package | The name of the encapsulated package | A set of related classes, Function encapsulated package name |
@param | such as $username username | variable meaning comment |
@return | If the function returns a bool | function returns a description of the result, it is generally not used in a void (empty return result) function |
@see | Such as Class Login() | Any element associated with the file (global variables, including pages, classes, functions, definitions, methods, variables). |
@since | version | Record when changes were made to which parts of the document |
@static | Record static classes and methods | |
@staticvar | ||
##Sub version |
||
Exception thrown by a certain method |
||
Indicates areas where the file is incomplete or needs to be improved |
||
type | Variables in the document and their types | |
Version information of documents, classes, and functions |
- | @see | @link |
---|---|---|
External link | √ | √ |
Internal program | √ | X |
Variable\
Format@var [Type] [Variable name] [<description>]</description>
\
For example@var int id user id
Variable type | Description |
---|---|
string | String |
integer/int | number/int type |
boolean/bool | false/true |
number/floating point number | |
Object instance | |
Specified class | |
Any type | |
Array, can be specified as an array of the specified type | |
File resource type | |
No return value | |
- | |
Executable callback function | |
No A method that must be executed | |
Current instance |
2. Variable definition inside the method
Format
@throws [Type] [\
For example
@throws Exception
##
The above is the detailed content of Comment tags that every PHPer should master!. For more information, please follow other related articles on the PHP Chinese website!