PHP parameter comments

Source: Internet
Author: User
Tags php source code
Introduction: This is the PHP parameter comment detailed page, introduced and PHP, related knowledge, skills, experience, and some PHP source code and so on.

class= ' pingjiaf ' frameborder= ' 0 ' src= ' http://biancheng.dnbcw.info/pingjia.php?id=340853 ' scrolling= ' no ' >

All of the documentation comments are a multiline comment starting with/**, called DocBlock in Phpdocumentor, and DocBlock is a software developer's help on a keyword that allows others to know what the keyword is for and how to use it. Phpdocumentor Specifies that a DocBlock contains the following information:
1. Function Summary Area
2. Detailed Description Area
3. Mark Tag
The first line of the document comment is the function description area, which is usually a concise description of the function of the class, method, or function, and the body of the function summary will be displayed in the index area in the generated document. The contents of the function description area can be either a blank line or a. To end
After the function description area is a blank line, followed by the detailed description area. This part of the main is to explain the functionality of your API, use, if possible, there can be examples of usage and so on. In this section, you should focus on the usual use of your API functions or methods, use them, and indicate whether it is cross-platform (if any), for information related to the peace table, you have to distinguish it from those common information, usually by another line, Then write down the considerations or special information on a particular platform that should be sufficient so that your readers can write the appropriate test information, such as boundary conditions, parameter ranges, breakpoints, and so on.
After that is also a blank line, then the document tag tag, indicating some technical information, mainly the most important is the call parameter type, return value is extremely type, inheritance relationship, related methods/functions and so on.
For more information on document tagging, refer to section Fourth: Document tagging.
The documentation comments can also be used 这样的标签,详细介绍请参考附录二。
下面是一个文档注释的例子
for example

/**
* Function add to achieve two number of additions
*
* A simple addition calculation, the function accepts two numbers A, B, returns their and C
*
* @param int Addend
* @param int Summand
* @return Integer
*/
function Add ($a, $b) {
return $a + $b;
}

The resulting document is as follows:
Add
Integer ADD (int $a, int $b)
[Line 45]
function Add, implement two number of additions
Constants A simple addition calculation, the function accepts two numbers A, B, returns their and C
Parameters
? int $a-Addend
? int $b-Summand
5. Document Tags:
The use of a document tag is a keyword, or other document tag, that the tag can be used to decorate.
All document tags begin with a * after each line. If the mark of @ is out of the middle of a paragraph, the tag will be ignored as normal content.
@access
Scope of Use: Class,function,var,define,module
The tag is used to indicate access rights for the keyword: private, public, or proteced
@author
Specify the author
@copyright
Scope of Use: Class,function,var,defi

Scope of Use: Define
Constants used to indicate define in PHP
@final
Scope of Use: Class,function,var
Indicates that the keyword is a final class, method, property, prohibit derivation, modification.
@filesource
Similar to example, except that the tag directly reads and displays the contents of the currently parsed PHP file.
@global
Indicates the global variable referenced in this function
@ingore
Used to omit the specified keyword from the document
@license
Equivalent to the HTML tag, first the URL, followed by the content to be displayed
such as Baidu
Can write @license http://www.baidu.com Baidu
@link
Similar to license
But you can also refer to any one of the keywords in the document by using link
@name
Specifies an alias for the keyword.
@package
Scope of Use: page-level, define,function,include
Class-Level->class,var,methods
Used to logically divide one or several keywords into a group.
@abstrcut
Indicates that the current class is an abstract class
@param
Indicates the parameters of a function
@return
Indicates that the return of a method or function refers to the
@static
Indicates that the off-build word is static.
@var
Indicate variable type
@version
Specifying version information
@todo
Identify areas that should be improved or not implemented
@throws
Indicates that this function may throw an error exception, which can occur in extreme cases
As mentioned above, ordinary document tag tags must be at the beginning of each line at the @ mark, in addition, there is a tag called inline tag, with {@}, including the following:
{@link}
Usage with @link
{@source}
Show the contents of a function or method
6. Some annotation specifications
A. The comment must be
/**
* XXXXXXX
*/
The form
B. For a function that references a global variable, you must use the glboal tag.
C. For variables, the type must be marked with VAR (int,string,bool ... )
D. Functions must indicate their arguments and return values through the Param and return tags
E. For keywords that appear two or more times or more than two times, you need to ignore the excess by ingore and keep only one
F. Where other functions or classes are called, use link or other tags to link to the appropriate section for easy document reading.
G. Use non-document annotations where necessary to improve code legibility.
H. Descriptive content as concise as possible, using phrases rather than sentences.
I. Global variables, static variables and constants must be indicated by corresponding tags
7. Summary
Phpdocumentor is a very powerful document auto-generation tool that helps us write specification annotations, generate easy-to-understand, well-structured documents, and can help with our code upgrades, maintenance, handover, and more.
For more detailed instructions on phpdocumentor, you can go to its official website
http://manual.phpdoc.org/Check
8. Appendix
Appendix 1:
Keywords that can be identified by Phpdoc:
Include
Require
Include_once
Require_once
Define
function
Global
Class
Appendix 2
Tags that can be used in a document










    • Appendix III:
      A PHP code that contains a specification comment:

                * @version 1.0* @package sample*///sample file #1/*** Dummy include value, to demonstrate the parsing power of Phpdocumen Tor*/include_once ' sample3.php ';/*** special global variable declaration docblock* @global integer $GLOBALS [' _myvar ']* @ Name $_myvar*/$GLOBALS [' _myvar '] = 6;/*** constants*//*** First constant*/define (' testing ', 6);/*** second constant*/ Define (' Anotherconstant ', strlen (' Hello '));/*** A sample function docblock* @global string Document the fact that it's fun Ction uses $_myvar* @staticvar integer $staticvar This was actually what's returned* @param string $param 1 name to declare * @param string $param 2 value of the name* @return integer*/function firstfunc ($param 1, $param 2 = ' optional ') {/*** A Samp Le private variable, this can is hidden with the--parseprivate* option* @accessprivate * @var Integer|string*/var $firstva r = 6;/*** @link http://www.example.com example link* @see MyClass () * @uses testing, anotherconstant* @var Array*/var $sec Ondvar =array (' stuff ' =                 Array (6, 17, ' Armadillo '), testing = anotherconstant);/*** Constructor sets up {@link $fi Rstvar}*/function MyClass () {$this->firstvar = 7;}  /*** Return a thingie based on $paramie * @param boolean $paramie * @return integer|babyclass*/function parentfunc ($paramie) {if ($paramie) {return 6;} else {return new Babyclass;}}} /*** @package Sample1*/class Babyclass extends MyClass {/*** The answer to life, the Universe and everything* @var integer */var $secondvar = 42;/*** Configuration values* @var array*/var $thirdvar;/*** Calls Parent constructor, then increments {@link $firstvar}*/function babyclass () {parent::myclass (); $this->firstvar++;} /*** This returns a myclass* @param ignored $paramie * @return myclass*/function parentfunc ($paramie) {return new my class;}}? >

      Love EE focus on Java Michael Jackson Video station JSON online tool

      Http://biancheng.dnbcw.info/php/340853.html Pageno:6
  • 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.