Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comments for PHP class and functions?

Tags:

I would like to add some documentation comments for my (PHP) class and its functions in some standard format, so that it’s easier for others to understand.

What would an example of how you would write comments for the following class and function?

Information about the class:

Classname Photos: it has some functions related to uploading the photo and displaying the photos. Function names are upload(), display(), delete().

Information about the upload function:

Uploads the resizes and uploads the image and has few parameters as shown below.

<?php     class Photos extends CI_Controller     {         public function upload($file_name, $new_name, $new_width, $new_height, $directory)         {             ...             ...             returns true or false.         }  ?> 
like image 409
sunjie Avatar asked Jul 06 '11 07:07

sunjie


1 Answers

PHPDocumentor style is pretty standard and understood by most IDE's and documentation generators.

  /**    * Photos    *     *     * @package    CI    * @subpackage Controller    * @author     YOUR NAME <[email protected]>    */   class Photos extends CI_Controller   {        /**        *         * Uploads a file        *        * @param string $file_name  description        * @param string $new_name  description        * @param integer $new_width  description        * @param integer $new_height  description        * @param string $directory  description        * @return boolean        */       public function upload($file_name, $new_name, $new_width, $new_height, $directory)       {        }    } 
like image 152
prodigitalson Avatar answered Sep 20 '22 22:09

prodigitalson