php - PHP 类和函数的注释

标签 php syntax comments standards

我想以某种标准格式为我的 (PHP) 类及其函数添加一些文档注释,以便其他人更容易理解。

您将如何为以下类和函数编写注释的示例是什么?

类(class)信息:

Classname Photos:它有一些与上传照片和显示照片相关的功能。函数名称为 upload()display()delete()

上传功能说明:

上传调整大小并上传图像,参数很少,如下所示。

<?php
    class Photos extends CI_Controller
    {
        public function upload($file_name, $new_name, $new_width, $new_height, $directory)
        {
            ...
            ...
            returns true or false.
        }

?>

最佳答案

PHPDocumentor样式非常标准,大多数 IDE 和文档生成器都能理解。

  /**
   * Photos
   * 
   * 
   * @package    CI
   * @subpackage Controller
   * @author     YOUR NAME <YOUREMAIL@domain.com>
   */
  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)
      {

      }
   }

关于php - PHP 类和函数的注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6592962/

相关文章:

C 编程?使用指针

c - 评论中的 "@(#)"是什么意思?

comments - 从 LiveFyre 迁移评论?

php - Ratchet (php) 使用类 MessageComponentInterface 和 WampServerInterface 一起使用 websockets 和推送通知

php - Apache 和 MySQL 正在运行,但 "http://localhost/phpmyadmin/"显示 "This webpage is not available"

javascript - 与 Reactjs 语法的混淆

haskell - 保护语法中的逗号有什么作用?

emacs - 如何在 emacs 上保留对通过 "M-x customize"设置的变量的注释?

php - 将mysql表的内容迁移到另一个表

php - 为什么这个 PHP activerecord 关联不起作用?