注释标记

@access

  • 使用范围:class,function,var,define,module
  • 该标记用于指明关键字的存取权限:private、public或proteced

@author

  • 指明作者

@copyright

  • 使用范围:class,function,var,define,module,use
  • 指明版权信息

@deprecated

  • 使用范围:class,function,var,define,module,constent,global,include
  • 指明不用或者废弃的关键字

@example

  • 该标记用于解析一段文件内容,并将他们高亮显示。Phpdoc会试图从该标记给的文件路径中读取文件内容

@const

  • 使用范围:define
  • 用来指明php中define的常量

@final

  • 使用范围:class,function,var
  • 指明关键字是一个最终的类、方法、属性,禁止派生、修改。

@filesource

  • 和example类似,只不过该标记将直接读取当前解析的php文件的内容并显示。

@global

  • 指明在此函数中引用的全局变量

@ingore

  • 用于在文档中忽略指定的关键字

@license

  • 相当于html标签中的<a>,首先是URL,接着是要显示的内容
  • 例如<a href=”http://www.baidu.com”>百度</a>
  • 可以写作 @license http://www.baidu.com 百度

@link

  • 类似于license
  • 但还可以通过link指到文档中的任何一个关键字

@name

  • 为关键字指定一个别名。

@package

  • 使用范围:页面级别的-> define,function,include
  • 类级别的->class,var,methods
  • 用于逻辑上将一个或几个关键字分到一组。

@abstrcut

  • 说明当前类是一个抽象类

@param

  • 指明一个函数的参数

@return

  • 指明一个方法或函数的返回指

@static

  • 指明关建字是静态的。

@var

  • 指明变量类型

@version

  • 指明版本信息

@todo

  • 指明应该改进或没有实现的地方

@throws

  • 指明此函数可能抛出的错误异常,极其发生的情况
  • 普通的文档标记标记必须在每行的开头以@标记,除此之外,还有一种标记叫做inline tag,用{@}表示,具体包括以下几种:

{@link}

  • 用法同@link

{@source}

  • 显示一段函数或方法的内容

注释规范

a.注释必须是

/**
* 注释内容
*/

的形式

b.对于引用了全局变量的函数,必须使用glboal标记。

c.对于变量,必须用var标记其类型(int,string,bool…)

d.函数必须通过param和return标记指明其参数和返回值

e.对于出现两次或两次以上的关键字,要通过ingore忽略掉多余的,只保留一个即可

f.调用了其他函数或类的地方,要使用link或其他标记链接到相应的部分,便于文档的阅读。

g.必要的地方使用非文档性注释,提高代码易读性。

h.描述性内容尽量简明扼要,尽可能使用短语而非句子。

i.全局变量,静态变量和常量必须用相应标记说明

示例

<?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
*/ //PHP code /**
* 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;
}
?>

phpDocumentor官方网站


YII框架的注释范例:

/**
* CHttpSession提供了session级的数据管理和相关配置
*
* 开启session 调用 {@link open()};
* 完成和发送session数据,调用 {@link close()};
* 清除session,调用{@link destroy()}.
*
*
* CHttpSession can be used like an array to set and get session data. For example,
* <pre>
* $session=new CHttpSession;
* $session->open();
* $value1=$session['name1']; // get session variable 'name1'
* $value2=$session['name2']; // get session variable 'name2'
* foreach($session as $name=>$value) // traverse all session variables
* $session['name3']=$value3; // set session variable 'name3'
* </pre>
*
* The following configurations are available for session:
* <ul>
* <li>{@link setSessionID sessionID};</li>
* <li>{@link setSessionName sessionName};</li>
* <li>{@link autoStart};</li>
* <li>{@link setSavePath savePath};</li>
* <li>{@link setCookieParams cookieParams};</li>
* <li>{@link setGCProbability gcProbability};</li>
* <li>{@link setCookieMode cookieMode};</li>
* <li>{@link setUseTransparentSessionID useTransparentSessionID};</li>
* <li>{@link setTimeout timeout}.</li>
* </ul>
* See the corresponding setter and getter documentation for more information.
* Note, these properties must be set before the session is started.
*
* CHttpSession can be extended to support customized session storage.
* Override {@link openSession}, {@link closeSession}, {@link readSession},
* {@link writeSession}, {@link destroySession} and {@link gcSession}
* and set {@link useCustomStorage} to true.
* Then, the session data will be stored and retrieved using the above methods.
*
* CHttpSession is a Web application component that can be accessed via
* {@link CWebApplication::getSession()}.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id: CHttpSession.php 2497 2010-09-23 13:28:52Z mdomba $
* @package system.web
* @since 1.0
*/
class CHttpSession implements IteratorAggregate, ArrayAccess, Countable { /**
* @var boolean whether the session should be automatically started when the session application component is initialized, defaults to true.
*/
public $autoStart = true;
private static $_instance = NULL; /**
* Initializes the application component.
* This method is required by IApplicationComponent and is invoked by application.
*/
public function init() {
if ($this->autoStart) {
$this->open();
} register_shutdown_function(array($this, 'close'));
} /**
* Returns a value indicating whether to use custom session storage.
* This method should be overriden to return true if custom session storage handler should be used.
* If returning true, make sure the methods {@link openSession}, {@link closeSession}, {@link readSession},
* {@link writeSession}, {@link destroySession}, and {@link gcSession} are overridden in child
* class, because they will be used as the callback handlers.
* The default implementation always return false.
* @return boolean whether to use custom storage.
*/
public function getUseCustomStorage() {
return false;
} /**
* Session open handler.
* This method should be overridden if {@link useCustomStorage} is set true.
* Do not call this method directly.
* @param string $savePath session save path
* @param string $sessionName session name
* @return boolean whether session is opened successfully
*/
public function openSession($savePath, $sessionName) {
return true;
} // 截取了一部分 }

PHP命名规范

先了解下

1、什么是 驼峰命名法?  百度百科

2、大驼峰 与 小驼峰 的区别 ?   百度百科

1.类名:大驼峰命名法

2.类属性

public、protected类型的,小驼峰命名法;

private类型的,下划线(_)开头,小驼峰命名法;

3.类方法

public、protected类型的,小驼峰命名法;

private类型的,下划线(_)开头,小驼峰命名法;

4.类方法参数:小驼峰命名法;

5.函数:采用C GNU的惯例,所有的字母使用小写字母,使用下划线(_)分割单词;

6.函数参数:小驼峰命名法;

例如:

function some_bloody_function($userId, $userName) {

}

7.常量

所有字母都大写,使用下划线(_)分割单词;

PHP Document 注释标记及规范 && PHP命名规范的更多相关文章

  1. python基础(代码规范、命名规范、代码缩进、注释)

    代码规范 PEP8(python增强建议书第8版) 每个import语句只导入一个模块 不要在行尾添加分号";" 建议每行不超过80个字符   超出部分可以用()来进行换行例如: ...

  2. 前端开发规范:命名规范、html 规范、css 规范、js 规范

    上周小组的培训内容是代码可读性艺术,主要分享如何命名.如何优化代码排版,如何写好的注释.我们都知道写出优雅的代码是成为大牛的必经之路. 下面感谢一位前端开发小伙伴总结的前端开发规范,通过学习相关开发规 ...

  3. 前端开发规范:命名规范、HTML 规范、CSS 规范、JavaScript 规范

    一个好的程序员肯定是要能书写可维护的代码,而不是一次性的代码,怎么能让团队当中其他人甚至一段时间时候你再看你某个时候写的代码也能看懂呢,这就需要规范你的代码了.我是有一点强迫症的人,上周我们后端给我了 ...

  4. 前端开发规范之命名规范、html规范、css规范、js规范

    在学习编程的时候,每次看到那些整齐规范的代码,心里顿时对这个程序员表示点点好感,有时,比如看到自己和朋友写的代码时,那阅读起来就是苦不堪言,所以,一些基本的开发规范是必须的,是为了自己方便阅读代码,也 ...

  5. 浅谈Android编码规范及命名规范

    前言: 目前工作负责两个医疗APP项目的开发,同时使用LeanCloud进行云端配合开发,完全单挑. 现大框架已经完成,正在进行细节模块上的开发 抽空总结一下Android项目的开发规范:1.编码规范 ...

  6. python代码规范和命名规范

    一.简明概述 1.编码 如无特殊情况, 文件一律使用 UTF-8 编码 如无特殊情况, 文件头部必须加入#-*-coding:utf-8-*-标识 2.代码格式 2.1.缩进 统一使用 4 个空格进行 ...

  7. iOS代码规范之命名规范

    技术博客http://www.cnblogs.com/ChenYilong/    新浪微博http://weibo.com/luohanchenyilong   命名规范类命名    首字母大写,之 ...

  8. C#中的代码书写规范以及命名规范

    C#代码书写规则: 1. 尽量使用接口,然后使用类实现接口,以提高程序的灵活性. 2.一行不要超过80个字符 3.尽量不要手动更改计算机生成的代码 4.关键的语句写注释 5.建议局部变量在最接近使用它 ...

  9. CSS书写规范、命名规范、网易CSS框架NEC

    网易CSS框架NEC:http://nec.netease.com/ NEC框架的CSS规范:  CSS规范 - 分类方法 CSS规范 - 命名规则 CSS规范 - 代码格式 CSS规范 - 优化方案 ...

随机推荐

  1. 【WEB API项目实战干货系列】- 接口文档与在线测试(二)

    上一篇: [WEB API项目实战干货系列]- Web API 2入门(一) 这一篇我们主要介绍如何做API帮助文档,给API的调用人员介绍各个 API的功能, 输入参数,输出参数, 以及在线测试 A ...

  2. 支持Ajax跨域访问ASP.NET Web Api 2(Cors)的简单示例教程演示

    随着深入使用ASP.NET Web Api,我们可能会在项目中考虑将前端的业务分得更细.比如前端项目使用Angularjs的框架来做UI,而数据则由另一个Web Api 的网站项目来支撑.注意,这里是 ...

  3. Java泛型中E、T、K、V等的含义

     Java泛型中的标记符含义:  E - Element (在集合中使用,因为集合中存放的是元素) T - Type(Java 类) K - Key(键) V - Value(值) N - Numbe ...

  4. 网站性能工具Yslow的使用方法

    Yslow是雅虎开发的基于网页性能分析浏览器插件,从年初我使用了YSlow后,改变了博客模板大量冗余代码,不仅提升了网页的打开速度,这款插件还帮助我分析了不少其他网站的代码,之前我还特意写了提高网站速 ...

  5. 洛谷P2726 阶乘 Factorials

    题目背景 N的阶乘写作N!,表示小于等于N的所有正整数的乘积. 题目描述 阶乘会变大得很快,如13!就必须用32位整数类型来存储,到了70!即使用浮点数也存不下了. 你的任务是找到阶乘最前面的非零位. ...

  6. 洛谷P1134 阶乘问题

    题目描述 也许你早就知道阶乘的含义,N阶乘是由1到N相乘而产生,如: 12! = 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 = 479,001, ...

  7. 高效图片轮播,两个imageView实现

    本文是投稿文章,作者:codingZero 导语 在不少项目中,都会有图片轮播这个功能,现在网上关于图片轮播的框架层出不穷,千奇百怪,笔者根据自己的思路,用两个imageView也实现了图片轮播,这里 ...

  8. POJ2485Highways(prime 水题)

    Highways Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 26516   Accepted: 12136 Descri ...

  9. Emgu学习之(二)——图像读取、显示、保存

    visual Studio Community 2015 工程和源代码:http://pan.baidu.com/s/1o6u5Fdw 内容 在这篇文章中将提到以下内容: 从文件中读取图像 Image ...

  10. android 事件处理概念簇

    1)事件传递函数 2)事件相关: 事件.事件源.事件监听器.MotionEvent 3)坐标系.定位.路由: 4)Window activity view viewGroup