PHP Standard Comments

Source: Internet
Author: User

"PHP is a simple and easy to get started language, and it's possible for beginners to print out a Hello world with echo in less than a few minutes!" But is he a real programmer? How to define a programmer? If you want to really be a programmer, then you have to follow a set of program writing specifications, "

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?

/**
* @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
* @Const indicates constant
* @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.
* @include indicates information about the included files
* @link define an online connection
* @module define the module information for attribution
* @modulegroup module groups that define attribution
* @param defines parameter information for a function or method
* @since indicates which version of the API function or method was introduced from
* @var defines the description variable/property.
* @ VERSIONdefinition release 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<[email protected]>* @version     $Id $* @since        1.0* *


Function Header Comment

/* * * Some_func * Function meaning description * * @access public* @param mixed $arg 1 Parameter one description * @param mixed $arg 2 parameter two description * @param mixed $mixed This is a Mixed type * @since 1.0* @return array*/publicfunction thisisfunction ($string $integer $mixed) {returnarray();}


Comments for Class

/* * * A detailed description of the class (optional). )。 * @author         richard<[email protected]>* @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.  */$thissetconfig (); $this->createconfigfile ();  // Creating a configuration file $this->clearcache ();         // Clear Cache file $this->createdatafiles ();   // Generate Data Files $this-Prepareproxys (); $this->restart ();

PHP Standard Comments

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: info-contact@alibabacloud.com 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.