我喜欢PHP网站上的文档,因此我在内联注释中使用了类似内容,并使用了PHPDoc语法。请参见下面的示例。
/*
* Finds all the locations where you have access to for this client and returns them in an array .
* @author Radu
* @version 1.0
* @param int $id ( The id of the client for which you're requesting access. )
* @param object $db ( A resource of type Mysql, representing a connection to mysql database, if not supplied the function will connect itself. )
* @return array ( Returns array with id's of locations that you are allowed to see, an empty array if you do not have acces to any locations or returns FALSE and triggers a Warning if any error occuread )
* @use array allowed_locations ( $id [, $db] )
*/
function allowed_locations($id, $db=NULL){ ... }
就像@Larry Coleman所说的那样,内联注释应该告诉您为什么要编写一些代码。
$funcResult = SomeFunction();
if(is_array($funcResult))
{ //Beacause SomeFunction() could return NULL, and count(NULL) = 1
$c = count($funcResult);
} else {
$c = 0;
}
if($c == 1)
{
...
}else
{
...
}