PHP is a relatively easy to get started language, a lot of people are easy to start with, but in the course of your study, you also have to abide by the PHP Standard annotation specification.
We often write functions, but these functions can only be understood by themselves, and even after a period of time they do not know what they wrote, then how to do? The best way of course is to add comments to your own code.
We may be familiar with a lot of comments written in C pear php comments and so on, but we use the main still # and/**/.
#是一种简短的注释方法. Maybe you'll use it to annotate a variable, or call a method. /**/we're probably still using it to comment out a large piece of code, but how do you use it to annotate a function with a standard?
/**
* @name Name
* @abstract declaration variable/class/method
* @access indicates access to this variable, class, function/method
* @author function Author's name and email address
* @category Organization Packages
* @copyright Specify Copyright information
* @const Specified constants
* @deprecate indicate information that is not recommended or discarded
* @example Example
* @exclude indicates that the current comment will not be analyzed and does not appear in the text block
* @final indicates that this is a final class, method, property, prohibit derivation, modification.
* @global indicate the global variables referenced in this function
* @include indicate the information contained in the file
* @link define an online connection
* @module define the module information for attribution
* @modulegroup module groups that define attribution
* @package Define the information of the packages that belong to
* @param define parameter information for a function or method
* @return Define the return information of a function or method
* @see define functions, variables to be referenced, and add the corresponding super connections.
* @since indicates which version of the API function or method was introduced from
* @static indicates that variables, classes, functions are static.
* @throws indicates an error that could be thrown by this function, which is extremely occurring
* @todo indicate areas that should be improved or not implemented
* @var Define description variables/properties.
* @version define version information
*/
The information in the comments is comprehensive, there may be a lot of things we don't use, and the red ones are often used by us.
Example:
File Header Template
/** * This is a what file * * This file program is used to do what (detailed description, optional.) )。 * @author richard<e421083458@163.com> * @version $Id $ * @since 1.0 */
Function Header Comment
Description of/** * Some_func * Function * * * @access public * @param mixed $arg 1 parameter one * @param mixed $arg 2 parameter II * @param mixed $m Ixed This is a mixed type * @since 1.0 * @return Array * /Public Function thisisfunction ($string, $integer, $mixed) {return Array ( );}
Comments for Class
/** * Class Description * * Class details (optional). )。 * @author richard<e421083458@163.com> * @since 1.0 * * * class Test { }
Program code comments
1. The principle of annotation is to explain the problem clearly, not the more the better.
2. A number of statements as a logical block of code, the comment of this block can use the/* */method.
3. Specific comments to a statement, you can use the end of line Comment://.
/* Generate configuration files, data files. * /$this->setconfig (); $this->createconfigfile (); Create configuration file $this->clearcache (); Clear Cache file $this->createdatafiles (); Generate Data Files $this->prepareproxys (); $this->restart ();