国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 php手冊 PHP文件注釋標記及規(guī)范小結(jié)

PHP文件注釋標記及規(guī)范小結(jié)

Jun 13, 2016 pm 12:01 PM
class function php v document mark Comment specification

PHP 注釋標記

@access
使用范圍:class,function,var,define,module
該標記用于指明關(guān)鍵字的存取權(quán)限:private、public或proteced

@author
指明作者

@copyright
使用范圍:class,function,var,define,module,use
指明版權(quán)信息

@deprecated
使用范圍:class,function,var,define,module,constent,global,include
指明不用或者廢棄的關(guān)鍵字

@example
該標記用于解析一段文件內(nèi)容,并將他們高亮顯示。Phpdoc會試圖從該標記給的文件路徑中讀取文件內(nèi)容

@const
使用范圍:define
用來指明php中define的常量

@final
使用范圍:class,function,var
指明關(guān)鍵字是一個最終的類、方法、屬性,禁止派生、修改。

@filesource
和example類似,只不過該標記將直接讀取當前解析的php文件的內(nèi)容并顯示。

@global
指明在此函數(shù)中引用的全局變量

@ingore
用于在文檔中忽略指定的關(guān)鍵字

@license
相當于html標簽中的,首先是URL,接著是要顯示的內(nèi)容
例如
百度
可以寫作 @license http://www.baidu.com 百度

@link
類似于license
但還可以通過link指到文檔中的任何一個關(guān)鍵字

@name
為關(guān)鍵字指定一個別名。

@package
使用范圍:頁面級別的-> define,function,include
類級別的->class,var,methods
用于邏輯上將一個或幾個關(guān)鍵字分到一組。

@abstrcut
說明當前類是一個抽象類

@param
指明一個函數(shù)的參數(shù)

@return
指明一個方法或函數(shù)的返回指

@static
指明關(guān)建字是靜態(tài)的。

@var
指明變量類型

@version
指明版本信息

@todo
指明應該改進或沒有實現(xiàn)的地方

@throws
指明此函數(shù)可能拋出的錯誤異常,極其發(fā)生的情況

普通的文檔標記標記必須在每行的開頭以@標記,除此之外,還有一種標記叫做inline tag,用{@}表示,具體包括以下幾種:

{@link}
用法同@link

{@source}
顯示一段函數(shù)或方法的內(nèi)容

注釋規(guī)范

a.注釋必須是

/**
* 注釋內(nèi)容
*/

的形式

b.對于引用了全局變量的函數(shù),必須使用glboal標記。

c.對于變量,必須用var標記其類型(int,string,bool…)

d.函數(shù)必須通過param和return標記指明其參數(shù)和返回值

e.對于出現(xiàn)兩次或兩次以上的關(guān)鍵字,要通過ingore忽略掉多余的,只保留一個即可

f.調(diào)用了其他函數(shù)或類的地方,要使用link或其他標記鏈接到相應的部分,便于文檔的閱讀。

g.必要的地方使用非文檔性注釋,提高代碼易讀性。

h.描述性內(nèi)容盡量簡明扼要,盡可能使用短語而非句子。

i.全局變量,靜態(tài)變量和常量必須用相應標記說明

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Writing Effective PHP Comments Writing Effective PHP Comments Jul 18, 2025 am 04:44 AM

Comments cannot be careless because they want to explain the reasons for the existence of the code rather than the functions, such as compatibility with old interfaces or third-party restrictions, otherwise people who read the code can only rely on guessing. The areas that must be commented include complex conditional judgments, special error handling logic, and temporary bypass restrictions. A more practical way to write comments is to select single-line comments or block comments based on the scene. Use document block comments to explain parameters and return values at the beginning of functions, classes, and files, and keep comments updated. For complex logic, you can add a line to the previous one to summarize the overall intention. At the same time, do not use comments to seal code, but use version control tools.

Improving Readability with Comments Improving Readability with Comments Jul 18, 2025 am 04:46 AM

The key to writing good comments is to explain "why" rather than just "what was done" to improve the readability of the code. 1. Comments should explain logical reasons, such as considerations behind value selection or processing; 2. Use paragraph annotations for complex logic to summarize the overall idea of functions or algorithms; 3. Regularly maintain comments to ensure consistency with the code, avoid misleading, and delete outdated content if necessary; 4. Synchronously check comments when reviewing the code, and record public logic through documents to reduce the burden of code comments.

A Simple Guide to PHP Setup A Simple Guide to PHP Setup Jul 18, 2025 am 04:25 AM

The key to setting up PHP is to clarify the installation method, configure php.ini, connect to the web server and enable necessary extensions. 1. Install PHP: Use apt for Linux, Homebrew for Mac, and XAMPP recommended for Windows; 2. Configure php.ini: Adjust error reports, upload restrictions, etc. and restart the server; 3. Use web server: Apache uses mod_php, Nginx uses PHP-FPM; 4. Install commonly used extensions: such as mysqli, json, mbstring, etc. to support full functions.

WAMP Server PHP Configuration WAMP Server PHP Configuration Jul 18, 2025 am 04:26 AM

To adjust the PHP configuration of WAMPServer, you must first find the path of the php.ini file currently used, click the WAMP icon in the system tray, and hover over "PHP" and "php.ini" to display the correct position. Secondly, if you need to upload a large file, set upload_max_filesize and post_max_size to 64M, and restart Apache to take effect. Third, turn on display_errors=On and error_reporting=E_ALL in the debugging phase, change it to Off before going online and enable logging. Fourth, enable common extensions such as mysqli, curl, gd, mbstring and xm

Mastering PHP Block Comments Mastering PHP Block Comments Jul 18, 2025 am 04:35 AM

PHPblockcommentsareusefulforwritingmulti-lineexplanations,temporarilydisablingcode,andgeneratingdocumentation.Theyshouldnotbenestedorleftunclosed.BlockcommentshelpindocumentingfunctionswithPHPDoc,whichtoolslikePhpStormuseforauto-completionanderrorche

Mastering PHP Multiline Code Comments Mastering PHP Multiline Code Comments Jul 18, 2025 am 04:48 AM

PHPprovidestwomainwaystowritecomments:single-lineandmultiline,withthelatterbeingidealforlongerexplanationsordocumentation-stylenotesusingthe//syntax.Usemultilinecommentswhenwritingdetaileddescriptions(morethan2–3lines),documentingfunctionsorfileheade

Integrating PHP with Apache Integrating PHP with Apache Jul 18, 2025 am 04:50 AM

To make Apache support PHP, you need to install PHP and its Apache module. The steps are as follows: 1. Install PHP: sudoaptinstallphp; 2. Install Apache's PHP module: sudoaptinstalllibapache2-mod-php; 3. If the module is not automatically enabled, manually execute a2enmodphp; 4. Restart Apache: sudosystemctlrestartapache2. Make sure that AllowOverrideAll is in the site configuration and set DirectoryIndex to include index.php. Create a phpinfo() page during testing to verify whether it is

Learning PHP: A Beginner's Guide Learning PHP: A Beginner's Guide Jul 18, 2025 am 04:54 AM

TolearnPHPeffectively,startbysettingupalocalserverenvironmentusingtoolslikeXAMPPandacodeeditorlikeVSCode.1)InstallXAMPPforApache,MySQL,andPHP.2)Useacodeeditorforsyntaxsupport.3)TestyoursetupwithasimplePHPfile.Next,learnPHPbasicsincludingvariables,ech

See all articles