PHP experience-standard documentation for phpdoc PHP comments (translated from wiki)

Source: Internet
Author: User
Transferred from:PHP experience-standard documentation for phpdoc PHP comments (translated from wiki)

Document comments, nothing more than "//" and "/**/", write your ownCodeThat's all. Just write a few words as appropriate. However, one person will always be integrated into the team for a day. The team's communication will not be able to solve those comments with a single mouth, but also require general comments.

Phpdoc is a standard for PHP document comments. It can help us to standardize documents and make it easier to view others' code. The following table shows phpdoc on the Wiki I translated. For more information, see the original document.

Http://en.wikipedia.org/wiki/Phpdoc

References:

Http://manual.phpdoc.org/HTMLSmartyConverter/PHP/li_phpDocumentor.html

Http://www.ibm.com/developerworks/cn/linux/sdk/php/pear3/index.html

Http://www.phpdoc.org/docs/latest/index.html

Http://blog.csdn.net/eric6/article/details/5888894

 

Description of phpdoc annotation:

Mark Purpose Description
@ Abstract   Abstract class variables and Methods
@ Access Public, private or protected The access and use permissions of the document. @ access private indicates that the document is protected.
@ Author John <zhangsan@163.com> Document Author
@ Copyright Name time Document copyright information
@ Deprecated Version Document abolition Method
@ Deprec   Same as @ deprecated
@ Example /Path/to/Example The location of the sample file stored externally.
@ Exception   For exceptions thrown by methods in this document, refer to @ throws.
@ Global Type: $ globalvarname Global variables and related methods and functions in this document
@ Ignore   Ignore specified keywords in the document
@ Internal   Internal Development Team Information
@ Link URL Similar to license, but you can also find more detailed information in the document through link.
@ Name Variable alias Specify an alias for a variable
@ Magic   Phpdoc.de compatibility
@ Package Package name Package name of a group of related classes and function packages
@ Param For example, [$ username] User Name Variable description
@ Return If bool is returned Description of the returned result of the function, which is not used in void (empty return result) functions.
@ See For example, class login () Any element associated with the file (global variables, including, pages, classes, functions, definitions, methods, and variables ).
@ Since Version Record when to which part of the document has been changed
@ Static   Record static classes and Methods
@ Staticvar   Static variables used in classes and functions
@ Subpackage   Sub-version
@ Throws   An exception thrown by a method
@ Todo   Indicates the incomplete or complete file
@ VaR Type Variables and their types in this document
@ Version   Document, class, and function version information

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

English description:

Common tags
Tag Usage Description
@ Abstract   Documents an abstract class, class variable or method.
@ Access Public, private or protected Documents access control for an element. @ access private indicates that documentation of element be prevented.
@ Author Author name <author @ email> Documents the author of the current element.
@ Copyright Name Date Documents copyright information.
@ Deprecated Version Events a method as deprecated.
@ Deprec   Same as @ deprecated
@ Example /Path/to/Example Parameters the location of an external saved example file.
@ Exception   Events an exception thrown by a method-also see @ throws.
@ Global Type $ globalvarname Specified ents a global variable or its use in a function or method.
@ Ignore   Prevents the documentation of an element
@ Internal   Private Information for advanced developers
@ Link URL  
@ Name Global variable name Specifies an alias for a variable. For example, $ globals ['myvariable'] becomes $ myvariable
@ Magic   Phpdoc.de compatibility"Phpdocumentor tags ".
@ Package Name of a package Events a group of related classes and functions.
@ Param Type [$ varname] Description  
@ Return Type description This tag shoshould not be used for constructors or methods defined withVoidReturn type.[Citation needed]
@ See Element Events an association to any element (global variable, include, page, class, function, define, method, variable ).
@ Since Version Documents when a method was added to a class.
@ Static   Documents a static class or Method
@ Staticvar Type Events a static variable's use in a function or class
@ Subpackage    
@ Throws   Events an exception thrown by a method.
@ Todo   Specified ents things that need to be done to the code at a later date.
@ VaR Type A data type for a class variable
@ Version   Provides the version number of a class or method.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Phpdoc annotation example:

<? PHP  /*  ** Start page for WebAccess ** PHP version 5 ** @ category PHP * @ package psi_web * @ author Michael Cramer <BigMichi1@users.sourceforge.net> * @ Copyright 2009 phpsysinfo * @ license http://opensource.org/licenses/gpl-2.0.php GNU General Public license * @ version SVN: $ ID: class. webpage. inc. PHP 412 09: 45: 53z jacky672 $ * @ link http://phpsysinfo.sourceforge.net */    /*  ** Generate the dynamic webpage ** @ category PHP * @ package psi_web * @ author Michael Cramer <BigMichi1@users.sourceforge.net> * @ Copyright 2009 phpsysinfo * @ license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @ version release: 3.0 * @ link http://phpsysinfo.sourceforge.net  */   Class Webpage Extends Output Implements  Psi_interface_output {  /* ** Configured language ** @ var string  */       Private   $ _ Language  ;  /*  ** Configured template ** @ var string  */       Private   $ _ Template  ;  /*  ** All available templates ** @ var Array  */      Private   $ _ Templates = Array  ();  /*  ** All available ages ** @ var Array  */       Private   $ _ Ages = Array  ();  /*  ** Check for all extensions that are needed, initialize needed vars and read config. php  */      Public   Function  _ Construct () {parent :: _ Construct ();  $ This -> _ Gettemplatelist ();  $ This -> _ Getregistragelist ();}  /*  ** Checking config. php setting for template, if not supportet set phpsysinfo.css as default * Checking config. php setting for language, if not supported set en as default ** @ return void  */      Private   Function  _ Checktemplatelanguage (){  $ This -> _ Template = Trim  (Psi_default_template );  If (! File_exists (App_root. '/templates /'. $ This -> _ Template. ". CSS" )){  $ This -> _ Template = 'phpsysinfo' ;}  $ This -> _ Language = Trim  (Psi_default_lang );  If (! File_exists (App_root. '/Language /'. $ This -> _ Language. ". xml" )){  $ This -> _ Language = 'en' ;}}  /*  ** Get all available tamplates and store them in internal array ** @ return void  */       Private  Function  _ Gettemplatelist (){  $ Dirlist = Commonfunctions: GDC (app_root. '/templates /' );  Sort ( $ Dirlist  );  Foreach ( $ Dirlist   As   $ File  ){  $ Tpl_ext = Substr ($ File , Strlen ( $ File )-4 );  $ Tpl_name = Substr ( $ File , 0, Strlen ( $ File )-4 );  If ( $ Tpl_ext === ". CSS" ){ Array_push ( $ This -> _ Templates, $ Tpl_name  );}}}  /*  ** Get all available translations and store them in internal array ** @ return void  */       Private   Function  _ Getregistragelist (){  $ Dirlist = Commonfunctions: GDC (app_root. '/Language /' ); Sort ( $ Dirlist  );  Foreach ( $ Dirlist   As   $ File  ){  $ Lang_ext = Substr ( $ File , Strlen ( $ File )-4 ); $ Lang_name = Substr ( $ File , 0, Strlen ( $ File )-4 );  If ( $ Lang_ext = ". Xml" ){  Array_push ( $ This -> _ Ages, $ Lang_name  );}}} /*  ** Render the page ** @ return void  */       Public   Function  Run (){  $ This -> _ Checktemplatelanguage ();  $ TPL = New Template ("/templates/html/index_dynamic.html" );  $ TPL -> Set ("template ", $ This ->_ Template );  $ TPL -> Set ("templates ", $ This -> _ Templates );  $ TPL -> Set ("language ", $ This -> _ Language );  $ TPL -> Set ("Ages ", $ This -> _ Ages );  Echo   $ TPL -> Fetch ();}} ?>

 

 

 

 

 

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.