1. What is phpDocumentor? <br>PHPDocumentor is a tool written in PHP. For PHP programs with standard annotations, it can quickly generate API documents with cross-reference, indexing and other functions. The old version is phpdoc. Starting from 1.3.0, it has been renamed phpDocumentor. The new version adds support for php5 syntax. At the same time, documents can be generated by operating on the client browser, and the documents can be converted to PDF, HTML, There are several forms of CHM, which are very convenient. <br>When PHPDocumentor works, it will scan the PHP source code under the specified directory, scan the keywords, intercept the comments that need to be analyzed, then analyze the special tags in the comments, generate an xml file, and then based on the analyzed classes and Module information, establish corresponding indexes, generate xml files, and use customized templates to output files in the specified format for the generated xml files. <br>2. Install phpDocumentor <br>Like other modules under pear, the installation of phpDocumentor is also divided into two methods: automatic installation and manual installation. Both methods are very convenient: <br>a. Automatically install through pear <br>Enter at the command line <br>pear install PhpDocumentor <br>b. Manual installation <br>Download the latest version of PhpDocumentor (now 1.4.0) at http://manual.phpdoc.org/ and unzip the content. <br>3. How to use PhpDocumentor to generate documents <br>Command line method: <br>In the directory where phpDocumentor is located, enter <br>Php –h <br> to get a detailed parameter list, of which several important parameters are as follows: <br> -f File name to be analyzed, multiple files separated by commas <br> -d Directory to be analyzed, multiple directories separated by commas <br>-t Storage path of the generated document <br>-o Output Document format, the structure is output format: converter name: template directory. <br>For example: phpdoc -o HTML:frames:earthli -f test.php -t docs <br>Web interface generation
In the new phpdoc, in addition to generating documents on the command line, you can also generate documents on the client To generate documents by operating on the browser, the specific method is to first place the content of PhpDocumentor in the apache directory so that it can be accessed through the browser. After access, the following interface is displayed: <br>Click the files button and select the php file or files to be processed. folder, you can also ignore the processing of certain files by specifying Files to ignore under this interface. <br>Then click the output button to select the storage path and format of the generated document. <br>Finally click create, and phpdocumentor will automatically start generating the document. The progress and status of the generation will be displayed at the bottom. If successful, it will be displayed <br>Total Documentation Time: 1 seconds <br>done <br>Operation Completed!! <br>Then, we can view the generated document. If it is in pdf format, the name defaults to documentation.pdf. <br>4. Add standardized comments to PHP code <br>PHPDocument generates documents from the comments of your source code, so the process of commenting on your program is also the process of compiling documentation. <br>From this point of view, PHPdoc encourages you to develop good programming habits and try to use specifications and clear text to annotate your program. At the same time, it more or less avoids the asynchronous development of documents and document updates afterwards. Some questions. <br>In phpdocumentor, comments are divided into documentation comments and non-documentation comments. <br>The so-called documentation comments are multi-line comments placed in front of specific keywords. Specific keywords refer to keywords that can be analyzed by phpdoc, such as class, var, etc. For details, please refer to Appendix 1. <br> Comments that do not precede keywords or are not standardized are called non-documentation comments. These comments will not be analyzed by phpdoc and will not appear in the API document you generate. <br>3.2 How to write documentation comments: <br>All documentation comments are a multi-line comment starting with /**, which is called DocBlock in phpDocumentor. DocBlock refers to a key comment written by a software developer. The help information of the keyword allows others to know the specific purpose of this keyword and how to use it. PhpDocumentor stipulates that a DocBlock contains the following information: <br>1. Function brief description area <br>2. Detailed description area <br>3. Mark tag <br>The first line of the documentation comment is the function description area, and the text is generally Briefly describe the function of this class, method or function. The text of the brief function description will be displayed in the index area in the generated document. The content of the function description area can be ended by a blank line or. <br>After the function description area is a blank line, followed by a detailed description area. This part mainly describes the function and purpose of your API in detail, if possible , you can also give examples of usage, etc. In this section, you should focus on clarifying the general purpose and usage of your API functions or methods, and indicate whether it is cross-platform (if involved). For platform-related information, you should treat it differently from general information. , the usual approach is to start a new line, and then write the precautions or special information on a specific platform. This information should be enough so that your readers can write corresponding test information, such as boundary conditions, parameter ranges, Breakpoints, etc. After <br> there is also a blank line, and then the document tag, indicating some technical information, mainly the call parameter type, return value and type, inheritance relationship, related methods/functions, etc.
Regarding document tags, please refer to Section 4: Document Tags for details. <br>You can also use tags such as in document comments. Please refer to Appendix 2 for details. <br>The following is an example of a documentation comment<br>/**<br>* Function add, implements the addition of two numbers <br>* <br>* A simple addition calculation, the function accepts two numbers a and b, and returns their sum c <br>* <br>* @ param int addend<br>* @param int addend<br>* @return integer <br>*/ <br>function Add($a, $b) { <br>return $a+$b; <br>} <br> The generated document is as follows: <br>Add <br>integer Add( int $a, int $b) <br>[line 45] <br>Function add to implement the addition of two numbers<br>Constants A simple addition calculation , the function accepts two numbers a and b, and returns their sum c <br>Parameters <br>• int $a - addend <br> • int $b - summand <br>5. Document tag: <br>The usage scope of document tag refers to the keywords or other document tags that the tag can be used to modify. <br>All documentation tags begin with @ after the * on each line. If the @ mark appears in the middle of a paragraph, the mark will be treated as normal content and ignored. <br>@access <br>Usage scope: class, function, var, define, module <br>This tag is used to indicate the access permission of keywords: private, public or protected <br>@author <br>Indicate the author <br>@copyright <br>Usage scope: class, function, var, define, module, use <br>Indicate copyright information<br>@deprecated <br>Usage scope: class, function, var, define, module, constent , global, include <br>Indicates unused or obsolete keywords <br>@example <br>This tag is used to parse a piece of file content and highlight them. Phpdoc will try to read the file content from the file path given by this tag <br>@const <br>Using scope: define <br> Used to indicate the constant of define in php <br>@final <br>Using scope: class ,function,var <br> indicates that the keyword is a final class, method, or attribute, and derivation and modification are prohibited. <br>@filesource <br>Similar to example, except that this tag will directly read the content of the currently parsed php file and display it. <br>@global <br>Indicates the global variable referenced in this function <br>@ingore <br> is used to ignore the specified keyword in the document <br>@license <br> is equivalent to < in the html tag ;a>, first the URL, then the content to be displayed <br> For example, <a href="%E2%80%9Dhttp://www.baidu.com%E2%80%9D">Baidu</a> <br> can be written as @license http ://www.baidu.com Baidu <br>@link <br>Similar to license <br> but you can also point to any keyword in the document through link <br>@name <br>Specify a keyword Alias. <br>@package <br>Usage scope: page level -> define, function, include <br>Class level ->class, var, methods <br> is used to logically combine one or several keywords Assigned to a group. <br>@abstrcut <br>Indicates that the current class is an abstract class<br>@param <br>Specifies the parameters of a function<br>@return <br>Specifies the return pointer of a method or function<br>@static <br>Indicates that the Guan Jianzi is static. <br>@var <br>Indicate the variable type<br>@version <br>Indicate the version information<br>@todo <br>Indicate areas that should be improved or not implemented <br>@throws <br>Indicate that this function may Error exceptions thrown, extremely rare <br>As mentioned above, ordinary document tags must be marked with @ at the beginning of each line. In addition, there is also a tag called inline tag, using {@} Expressions include the following types: <br>{@link} <br>Usage is the same as @link <br>{@source} <br>Display the content of a function or method<br>6. Some comment specifications <br>a. Comments must be in the form of <br>/**<br>* XXXXXXX <br>*/ <br> <br>b. For functions that reference global variables, the glboal tag must be used. <br>c. For variables, their type must be marked with var (int, string, bool...) <br>d. The function must indicate its parameters and return value through param and return markers <br>e. For two occurrences For keywords used twice or more, the redundant ones should be ignored through ingore, and only one should be kept <br>f. Where other functions or classes are called, link or other tags should be used to link to the corresponding part to facilitate documentation. of reading. <br>g. Use non-documentation comments where necessary to improve code readability. <br>h. Keep descriptive content concise and to the point, using phrases rather than sentences whenever possible. <br>i. Global variables, static variables and constants must be described with corresponding tags<br>7. Summary<br>phpDocumentor is a very powerful automatic document generation tool. It can help us write standardized comments and generate easy-to-understand , clearly structured documents are very helpful for our code upgrade, maintenance, handover, etc.<br>For more detailed instructions about phpDocumentor, you can check it out on its official website <br>http://manual.phpdoc.org/ <br>8. Appendix <br><strong>Appendix 1: </strong> <br>Keywords that can be recognized by phpdoc: <br>Include <br>Require <br>include_once <br>require_once <br>define <br>function <br>global <br>class <br><strong>Appendix 2</strong> <br>Tags that can be used in documents<br><b> <br><code> <br><br> <br> <kdb> <br><li> <br><pre class="brush:php;toolbar:false"> <br></pre>
<ul> <br><samp> <br><var> <br><strong>Appendix 3: </strong> <br>A piece of php code with specification comments: <br><div class="codetitle">
<span style="CURSOR: pointer" onclick="doCopy('code53020')"><u>Copy the code </u></span> The code is as follows: </div>
<div class="codebody" id="code53020">
<br><?php <BR>/**<br>* Sample File 2, phpDocumentor Quickstart <br>* <br>* This file demonstrates the rich information that can be included in <br>* in-code documentation through DocBlocks and tags. <br>* @author Greg Beaver <br>* @version 1.0 <br>* @package sample <br>*/ <br>// sample file #1 <br>/**<br>* Dummy include value, to demonstrate the parsing power of phpDocumentor <br>*/ <br>include_once 'sample3.php'; <br>/**<br>* Special global variable declaration DocBlock <br>* @global integer $GLOBALS['_myvar'] <br>* @name $_myvar <br>*/ <br>$GLOBALS['_myvar'] = 6; <br>/**<br>* Constants <br>*/ <br>/**<br>* first constant <br>*/ <br>define('testing', 6); <br> /**<br>* second constant <br>*/ <br>define('anotherconstant', strlen('hello')); <br>/**<br>* A sample function docblock <br>* @global string document the fact that this function uses $_myvar <br>* @staticvar integer $staticvar this is actually what is returned <br>* @param string $param1 name to declare <br>* @param string $param2 value of the name <br>* @return integer <br>*/ <br>function firstFunc($param1, $param2 = 'optional ') { <br>static $staticvar = 7; <br>global $_myvar; <br>return $staticvar; <br>} <br>/**<br>* The first example class, this is in the same package as the <br>* procedural stuff in the start of the file <br>* @package sample <br>* @subpackage classes <br>*/ <br>class myclass { <br> /**<br>* A sample private variable, this can be hidden with the --parseprivate <br>* option <br>* @accessprivate <br>* @var integer|string <br>*/ <br>var $firstvar = 6; <br>/**<br>* @link http://www.example.com Example link <br>* @see myclass() <br>* @uses testing, anotherconstant <br>* @var array <br>*/ <br>var $secondvar = <br>array( <br>'stuff' => <br>array( <br>6, <br>17, <br>'armadillo' <br>), <br>testing => anotherconstant <br>); <br>/**<br>* Constructor sets up {@link $firstvar} <br>*/ <br>function myclass() { <br>$this->firstvar = 7; <br>} <br>/**<br>* Return a thingie based on $paramie <br>* @param boolean $paramie <br>* @return integer|babyclass <br>*/ <br>function parentfunc($paramie) { <br>if ($ paramie) { <br>return 6; <br>} else { <br>return new babyclass; <br>} <br>} <br>} <br>/**<br>* @package sample1 <br>*/ <br>class babyclass extends myclass { <br>/**<br>* The answer to Life, the Universe and Everything <br>* @var integer <br>*/ <br>var $secondvar = 42; <br>/**<br>* Configuration values <br>* @var array <br>*/ <br>var $thirdvar; <br>/**<br>* Calls parent constructor, then increments {@link $firstvar} <br> */ <br>function babyclass() { <br>parent::myclass(); <br>$this->firstvar++; <br>} <br>/**<br>* This always returns a myclass <br>* @param ignored $paramie <br>* @return myclass <br>*/ <br>function parentfunc ($paramie) { <br>return new myclass; <br>} <br>} <br>?> <br>
</div>
</var></samp>
</ul>
</li></kdb>

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Chinese version
Chinese version, very easy to use

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools
