As a language that is relatively easy to get started, many people can easily get started with php, but in the process of learning, you must also abide by PHP's standard comment specifications.
We often write some functions, but these functions may only be understood by ourselves. After a while, we may even not recognize what we wrote. So what should we do? The best way is of course to add comments to your code.
We may be familiar with many ways of writing comments, C pear PHP comments, etc., but the main ones we use are # and /**/.
# is a short comment method. Maybe you will use it to annotate a variable or call a method. /**/. We may still use it to comment out a large section of code. , but how to use it to standardly annotate a function?
/**
* @name Name
* @abstract Declaration of variables/classes/methods
* @access Specifies the access rights of this variable, class, function/method
* @author Name and email address of the function author Address
* @category Organization packages
* @copyright Specify copyright information
* @const Specify constant
* @deprecate Specify deprecated or obsolete information
* @example Example
* @exclude indicates that the current comment will not be analyzed and will not appear in the document
* @final indicates that this is a final class, method, or attribute, and derivation and modification are prohibited.
* @global specifies the global variables referenced in this function
* @include specifies the information of the included files
* @link defines the online connection
* @module defines the attributed module information
* @modulegroup defines the belonging module group
* @package defines the belonging package information
* @param defines the parameter information of the function or method
* @return defines the return information of the function or method
* @see defines the functions and variables that need to be referenced, and adds the corresponding hyperlinks.
* @since indicates which version the api function or method was introduced from.
* @static indicates that variables, classes, and functions are static.
* @throws Indicates the error exceptions that this function may throw, and the circumstances in which they occur
* @todo Indicates areas that should be improved or not implemented
* @var defines variables/attributes.
* @version Define version information
*/
The information in the comments is very comprehensive. There may be a lot that we don’t use. The red parts are the ones we often use.
Example:
File header template
/** *这是一个什么文件 * *此文件程序用来做什么的(详细说明,可选。)。 * @author richard<e421083458@163.com> * @version $Id$ * @since 1.0 */
Function header comment
/** * some_func * 函数的含义说明 * * @access public * @param mixed $arg1 参数一的说明 * @param mixed $arg2 参数二的说明 * @param mixed $mixed 这是一个混合类型 * @since 1.0 * @return array */ public function thisIsFunction($string, $integer, $mixed) {return array();}
Class comments
/** * 类的介绍 * * 类的详细介绍(可选。)。 * @author richard<e421083458@163.com> * @since 1.0 */ class Test { }
Program code comments
1. The principle of comments is to explain the problem clearly, not the more the better.
2. Several statements are used as a logical code block, and the comments of this block can be used in /* */ mode.
3. For comments specific to a certain statement, you can use end-of-line comments: //.
/* 生成配置文件、数据文件。*/ $this->setConfig(); $this->createConfigFile(); //创建配置文件 $this->clearCache(); // 清除缓存文件 $this->createDataFiles(); // 生成数据文件 $this->prepareProxys(); $this->restart();
Related recommendations:
The above is the detailed content of Specification guidelines for standard comments in PHP programs. For more information, please follow other related articles on the PHP Chinese website!

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov


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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
