2010-02-03 37 views
11

我們必須如何記錄(與phpDocumentor)定義與define()在PHP中的常量?什麼是正確的方式來記錄PHP常量(定義)與phpDocumentor

我什麼也沒有發現在這個文檔中,卻發現下面的例子(我沒有看到它的使用)在sample2.php:

/**#@+ 
* Constants 
*/ 
/** 
* first constant 
*/ 
define('testing', 6); 
/** 
* second constant 
*/ 
define('anotherconstant', strlen('hello')); 

誰能告訴我什麼是記錄常數的最佳方式在PHP與phpDocumentor?

回答

6

定義語句通常只用一個描述性文本進行註釋,所以基本上是如何評論它的。

要詳細瞭解DocBlock模板標籤/**#@+,請查看the manual page

+0

沒有特別的標籤是必要的。出現在示例頂部的「模板標籤」僅作爲將您的「常量」描述片段添加到每個單獨描述中的快捷方式(「第一個常量」,「第二個常量」)。只有確實需要將一些常見文本放入多個單獨的描述中時,才需要使用該模板標籤。 – ashnazg 2011-09-01 20:50:29

+0

所有鏈接都已死亡 – Loenix 2016-10-18 07:45:44

0

您在phpDoc.org the elements that can be documented

您還有an example of documenting a define()(第二段代碼和周圍段落)。

+2

該示例實際上試圖證明將函數foo()和函數的docblock之間夾雜的「define」語句錯誤地與定義的常量(而不是函數)關聯起來。在教程中我沒有看到一個有用的例子來顯示記錄常量,所以我找到了一個phpDocumentor文件本身...查看頁面底部(http://manual.phpdoc.org/ HTMLSmartyConverter /手/ __ filesource/fsource_phpDocumentor_Parsers_phpDocumentorConvertersXMLDocBookpeardoc2Tokenizer.php.html)。 – ashnazg 2011-09-01 20:58:19

+1

所有鏈接都已死亡 – Loenix 2016-10-18 07:45:39

+0

該項目更改了文檔的位置。新位置:https://phpdoc.org/docs/latest(對不起,我找不到我發佈的章節) – xOneca 2016-10-18 11:57:53

1
/** 
*@const 
*/ 
const testing=6; 
const anotherconstant=strlen('hello'); 

試試這個,你會看到它作爲恆

相關問題