Summary of PHPDocument code annotation specifications

Source: Internet
Author: User
This article provides a detailed summary and introduction of PHPDocument code annotation specifications. For more information, see 1. install phpjavasentor (command line installation is not recommended)
Download the latest PHPDoc at
Put it in the web server directory so that you can access
Click files and select the php file or folder to be processed.
You can also use the Files to ignore in the specified interface to ignore the processing of some Files.
Click the output button to select the path and format of the generated document.
Finally, click create. the phpbench entor will automatically generate the document.

2. how to write PHP Standard comments
All document tags start with @ after each line. If @ is marked in the middle of a passage, the mark will be ignored as common content.
@ Access: specifies the access permission for a keyword: private, public, or proteced. optional values: class, function, var, define, and module.
@ Author specify the author
@ Copyright: copyright information
@ Const usage scope: define is used to specify the define constant in php.
@ Final scope of use: class, function, var indicates that the keyword is a final class, method, and attribute, and cannot be derived or modified.
@ Global indicates the global variables referenced in this function.
@ Name specifies an alias for the keyword.
@ Package is used to logically group one or more keywords into one group.
@ Shortcut indicates that the current class is an abstract class.
@ Param indicates the parameter of a function.
@ Return indicates the return value of a method or function.
@ Static indicates that the word is static.
@ Var specifies the variable type
@ Version indicates the version information.
@ Todo: specifies the areas to be improved or not implemented.
@ Link can be used to indicate any keyword in the document.
@ Ingore is used to ignore specified keywords in the document.

Some annotation specifications
A. The comment must be
B. The glboal mark must be used for functions that reference global variables.
C. for variables, you must use var to mark their types (int, string, bool ...)
D. the function must specify its parameters and return values through param and return tags.
E. for keywords that appear twice or more times, ignore unnecessary keywords through ingore and retain only one keyword.
F. when other functions or classes are called, link or other markup should be used to link to the corresponding part for easy reading of the document.
G. use non-document comments (comments before keywords that cannot be recognized by PHPDOC) as necessary to improve ease of coding.
H. The descriptive content should be as concise as possible and use phrases instead of sentences as much as possible.
I. global variables, static variables and constants must be marked with corresponding descriptions

Keywords that can be recognized by phpdoc:

3. php code annotated in the standard format:
* File name (sample2.php)
* Function description (omitted)
* @ Author steve
* @ Version 1.0
* @ Package sample2
* Contains files
Include_once 'sample3. php ';
* Declare global variables
* @ Global integer $ GLOBALS ['_ myvar']
* @ Name $ _ myvar
$ GLOBALS ['_ myvar'] = 6;
* Declare a global constant
Define ('num', 6 );
* Class name
* Class function description
* @ Package sample2
* @ Subpackage classes (if it is a parent class, add it)
Class myclass {
* Declare common variables
* @ Accessprivate
* @ Var integer | string
Var $ firstvar = 6;
* Create a constructor {@ link $ firstvar}
Function myclass (){
$ This-> firstvar = 7;
* Define functions
* Function description
* @ Global string $ _ myvar
* @ Staticvar integer $ staticvar
* @ Param string $ param1
* @ Param string $ param2
* @ Return integer | string
Function firstFunc ($ param1, $ param2 = 'optional '){
Static $ staticvar = 7;
Global $ _ myvar;
Return $ staticvar;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.