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

Source: Internet
Author: User
Tags deprecated

Document comments, nothing more than "//" and "/**/" two, write their own code, so point, appropriate to write a few sentences just fine; but a person always has a day in the team, team communication is not that a few comments and a mouth can solve, but also need a common annotation standard.

Phpdoc is a standard for PHP documentation comments, which helps us to have a specification when commenting on a document, which is more convenient when looking at someone else's code. The following table is my translation of the wiki on the Phpdoc, the level of personal English is limited, can refer to the original text.

Document translation from: Http://

Mark Use Description
@abstract Variables and methods for abstract classes
@access Public, private or protected Access and use permissions for the document. @access private indicates that the document is protected.
@author Zhang San <[email protected]> Document author
@copyright Name time Document copyright information
@deprecated Version Methods that are abolished in the document
@deprec Same @deprecated
@example /path/to/example The location of the sample file that is saved externally to the document.
@exception Exceptions that are thrown by methods in the document can also be referenced @throws.
@global Type: $globalvarname Global variables and related methods and functions in a document
@ignore Ignore keywords specified in the document
@internal Development team Internal Information
@link Url Similar to license but you can also find more detailed information in a document by link
@name Variable aliases Assign an alias to a variable
@magic compatibility
@package The name of the package package A set of related classes, package names encapsulated by functions
@param such as [$username] User name Variable meaning comment
@return If you return bool function returns the result description, generally not in the function of void (empty return result)
@see such as Class Login () Any element associated with the file (global variables, including, pages, classes, functions, definitions, methods, variables).
@since Version Record when changes are made to which parts of the document
@static Record static classes, methods
@staticvar Static variables used in classes, functions
@subpackage Child version
@throws Exception thrown by a method
@todo Indicates that the file has not been completed or is to be perfected
@var Type Variables and their types in the document
@version Version information for documents, classes, functions


code example

<?PHP/** * Start page for webaccess * * PHP version 5 * * @category php * @package psi_web * @author Michael Cra Mer <[email protected]> * @copyright phpsysinfo * @license GNU G Eneral Public License * @version SVN: $Id: Class. 412 2010-12-29 09:45:53z Jacky672 $ * @link*/  /** * generate the Dynamic webpage * * @category PHP * @package psi_web * @author Michael Cramer <[email p rotected]> * @copyright phpsysinfo * @license GNU general public Li Cense * @version release:3.0 * @link*/ classWebpageextendsOutputImplementsPsi_interface_output {/** * Configured language * * @var String*/     Private $_language; /** * configured template * * @var String*/     Private $_template; /** * All available templates * * @var Array*/     Private $_templates=Array(); /** * All Available languages * * @var Array*/     Private $_languages=Array(); /** Check for all extensions that is needed, initialize needed VARs and read config.php*/      Public function__construct () {Parent::__construct (); $this-_gettemplatelist (); $this-_getlanguagelist (); }         /** * Checking config.php setting for template, if not supportet set PHPSYSINFO.CSS as default * checking conf ig.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_getlanguagelist () {$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->_languages,$lang _name); }         }     }         /** * render the page * * @return void*/      Public functionrun () {$this-_checktemplatelanguage (); $TPL=NewTemplate ("/templates/html/index_dynamic.html"); $TPL->set ("template",$this-_template); $TPL->set ("Templates",$this-_templates); $TPL->set ("Language",$this-_language); $TPL->set ("Languages",$this-_languages); Echo $TPL-fetch (); } } ?>

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

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.