当前位置: 移动技术网 > IT编程>开发语言>PHP > PDP Document 代码注释规范第1/2页

PDP Document 代码注释规范第1/2页

2019年05月09日  | 移动技术网IT编程  | 我要评论
1. 什么是phpdocumentor ? phpdocumentor是一个用php写的工具,对于有规范注释的php程序,它能够快速生成具有相互参照,索引等功能的api文档

7. 总结
phpdocumentor是一个非常强大的文档自动生成工具,利用它可以帮助我们编写规范的注释,生成易于理解,结构清晰的文档,对我们的代码升级,维护,移交等都有非常大的帮助。
关于phpdocumentor更为详细的说明,可以到它的官方网站
http://manual.phpdoc.org/查阅
8.附录
附录1:
能够被phpdoc识别的关键字:
include
require
include_once
require_once
define
function
global
class
附录2
文档中可以使用的标签
<b>
<code>
<br>
<kdb>
<li>
<pre>
<ul>
<samp>
<var>
附录三:
一段含有规范注释的php代码
复制代码 代码如下:

<?php
/**
* sample file 2, phpdocumentor quickstart
*
* this file demonstrates the rich information that can be included in
* in-code documentation through docblocks and tags.
* @author greg beaver <cellog@php.net>
* @version 1.0
* @package sample
*/
// sample file #1
/**
* dummy include value, to demonstrate the parsing power of phpdocumentor
*/
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 this function uses $_myvar
* @staticvar integer $staticvar this is actually what is returned
* @param string $param1 name to declare
* @param string $param2 value of the name
* @return integer
*/
function firstfunc($param1, $param2 = 'optional')
{
static $staticvar = 7;
global $_myvar;
return $staticvar;
}
/**
* the first example class, this is in the same package as the
* procedural stuff in the start of the file
* @package sample
* @subpackage classes
*/
class myclass {
/**
* a sample private variable, this can be hidden with the --parseprivate
* option
* @access private
* @var integer|string
*/
var $firstvar = 6;
/**
* @link http://www.example.com example link
* @see myclass()
* @uses testing, anotherconstant
* @var array
*/
var $secondvar =
array(
'stuff' =>
array(
6,
17,
'armadillo'
),
testing => anotherconstant
);
/**
* constructor sets up {@link $firstvar}
*/
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 always returns a myclass
* @param ignored $paramie
* @return myclass
*/
function parentfunc($paramie)
{
return new myclass;
}
}
?>
2

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网