建议你应该使用非文档性质的注释来诠释你的代码,当你看到一段代码时想:哦,我想不需要在文档里去仔细描述它吧。那么你最好给这段代码作一个简单的注释,这样防止你会忘记它们是如何工作的。对于注释的形式,C的 /* */和C++的//都不错,不过,不要使用Perl或者shell的#注释方式。
包含代码:
无论什么时候,当你需要无条件包含进一个class文件,你必须使用requre_once;当你需要条件包含进一个class文件,你必须使用include_once;这样可以保证你要包含的文件只会包含一次,并且这2个语句共用同一个文件列表,所以你无须担心二者会混淆,一旦require_once 包含了一个文件,include_once不会再重复包含相同的文件,反之亦然。
PHP代码标记:
任何时候都要使用定义你的php代码,而不要简单地使用 ?>,这样可以保证PEAR的兼容性,也利于跨平台的移植。
文件头的注释声明:
所有需要包含在PEAR核心发布的PHP代码文件,在文件开始的时候,你必须加入以下的注释声明: /* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4.0|
// +----------------------------------------------------------------------+
// | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at|
// | http://www.php.net/license/2_02.txt.|
// | If you did not receive a copy of the PHP license and are unable to|
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately.|
// +------------------------------
