PHP - Documentation

From XennisWiki
Jump to: navigation, search

This article gives an example of how to document PHP code.

Example

Include class
/**
 * @see Zend_Gdata
 */
require_once 'Zend/Gdata.php';
Variable
/**
 * Galerie ID
 *
 * @var int
 */
private $id;
Function
/**
 * Outputs the pagination.
 *
 * @param  int      $id   Gallery ID
 * @param  int      $page Page number
 * @param  string   $sort Page sorting
 * @param  int|null $num  Number of photos per page
 * @throws Exception If $id is not an integer
 * @return boolean If output was successful
 */
public function outputPagination($id, $page, $sort, $num = NULL) {
    if( !is_int( $id ) ){
        throw new Exception('ID is not an intger!');
    }
    ...
    if( ... ) {
        return true;
    } else {
        return false;
    }
}

See also