Home Backend Development PHP Problem The php language supports several comment styles

The php language supports several comment styles

Feb 15, 2022 pm 02:05 PM
Comment php language Comment style

php language supports 3 comment styles: 1. C style, using the "//" symbol and the syntax "//comment content"; 2. C language style, using the "/* */" symbol and the syntax "/* Comment content */"; 3. Shell style (Perl style), using the "#" symbol and the syntax "#Comment content".

The php language supports several comment styles

The operating environment of this tutorial: windows7 system, PHP version 8.1, DELL G3 computer

PHP supports 3 comment styles: C, C and Unix Shell style (Perl style)

① Single-line comment (C style), symbol: //

②Multi-line comment (C style), symbol: /* */

③Special single-line comments (not commonly used, Shell style), symbol:

#1. C-style (//) comments

This kind of comment cannot appear ?> mark. If the short_open and asp_tag settings are turned on, &gt ; and %> also cannot appear in comments

<?php
echo "单行注释" ;//一般在代码右边少量说明或写在代码前面使之失效
?>
Copy after login

2. C language style (/* */), nested comments are not allowed

<?php
echo "多行注释" ;
echo "多行注释" ;
/*
一般说明脚本的相关信息,如版本,版权,作者日期等
使一长段代码失效
*/
?>
Copy after login

C-style comments will end when encountering the first "*/", so multi-line comments cannot be nested, otherwise a syntax error will be reported.

3. Shell style (#), same as C ban

<?php
echo "单行注释" ;#一般在代码右边少量说明或写在代码前面使之失效
?>
Copy after login

The three comment styles are as follows

The php language supports several comment styles

Note: Single-line comments are only commented to the end of the line or the current PHP code block ("?>" at the end of the line will not be commented, and PHP encounters "?> " will jump out of PHP mode, and then parse HTML code or other)

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of The php language supports several comment styles. For more information, please follow other related articles on the PHP Chinese website!

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

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.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Conveniently use PyCharm shortcut keys to implement multi-line comments Conveniently use PyCharm shortcut keys to implement multi-line comments Jan 27, 2024 am 08:02 AM

PyCharm multi-line comment shortcut keys: Make code comments more convenient and require specific code examples. In daily programming work, code comments are a very important part. It not only improves the readability and maintainability of the code, but also helps other developers understand the intent and design ideas of the code. However, manually adding code comments is often a time-consuming and tedious task. In order to make our code comments more efficient, PyCharm provides shortcut keys for multi-line comments. In PyCharm, we can use Ctrl+/

How to deal with request header errors in PHP language development? How to deal with request header errors in PHP language development? Jun 10, 2023 pm 05:24 PM

In PHP language development, request header errors are usually caused by some problems in HTTP requests. These issues may include invalid request headers, missing request bodies, and unrecognized encoding formats. Correctly handling these request header errors is the key to ensuring application stability and security. In this article, we will discuss some best practices for handling PHP request header errors to help you build more reliable and secure applications. Checking the request method The HTTP protocol specifies a set of available request methods (e.g. GET, POS

How to Optimize the Maintainability of Java Code: Experience and Advice How to Optimize the Maintainability of Java Code: Experience and Advice Nov 22, 2023 pm 05:18 PM

How to Optimize the Maintainability of Java Code: Experience and Advice In the software development process, writing code with good maintainability is crucial. Maintainability means that code can be easily understood, modified, and extended without causing unexpected problems or additional effort. For Java developers, how to optimize the maintainability of code is an important issue. This article will share some experiences and suggestions to help Java developers improve the maintainability of their code. Following standardized naming rules can make the code more readable.

How to add notes to saved passwords on iPhone How to add notes to saved passwords on iPhone Feb 28, 2024 pm 07:41 PM

iCloud Keychain makes it easier to manage your passwords without relying on memorizing or guessing website or usernames. You can do this by adding notes to existing passwords for apps and websites in iCloud Keychain. In this post, we will explain how to add notes to the passwords you save in iCloud Keychain on iPhone. Requirements There are some requirements you need to meet to use this new feature in iCloud Keychain. iPhone running iOS 15.4 or later Passwords stored in iCloud Keychain A valid Apple ID A valid internet connection How to add notes to saved passwords It goes without saying that you should store some passwords in iCloud Keychain

PyCharm Annotation Operation Guide: Optimizing the Code Writing Experience PyCharm Annotation Operation Guide: Optimizing the Code Writing Experience Feb 21, 2024 pm 06:27 PM

PyCharm Comment Operation Guide: Optimizing the Code Writing Experience In daily code writing, comments are a very important part. Good comments not only improve the readability of your code, but also help other developers better understand and maintain the code. As a powerful Python integrated development environment, PyCharm also provides rich functions and tools in terms of annotation, which can greatly optimize the code writing experience. This article will introduce how to perform annotation operations in PyCharm and how to utilize PyCharm's annotations.

How to use Behat in PHP programming? How to use Behat in PHP programming? Jun 12, 2023 am 08:39 AM

In PHP programming, Behat is a very useful tool that can help programmers better understand business requirements during the development process and ensure the quality of the code. In this article, we will introduce how to use Behat in PHP programming. 1. What is Behat? Behat is a behavior-driven development (BDD) framework that couples PHP code through language description (use cases written in Gherkin language), thereby enabling code and business requirements to work together. Use Behat to do

How to use Phpt for unit testing in PHP How to use Phpt for unit testing in PHP Jun 27, 2023 am 08:35 AM

In modern development, unit testing has become a necessary step. It can be used to ensure that your code behaves as expected and that bugs can be fixed at any time. In PHP development, Phpt is a very popular unit testing tool, which is very convenient to write and execute unit tests. In this article, we will explore how to use Phpt for unit testing. 1. What is PhptPhpt is a simple but powerful unit testing tool, which is part of PHP testing. Phpt test cases are a series of PHP source code snippets whose

Share tips for quickly commenting code in PyCharm to improve work efficiency Share tips for quickly commenting code in PyCharm to improve work efficiency Jan 04, 2024 pm 12:02 PM

Improved efficiency! Sharing the method of quickly commenting code in PyCharm In daily software development work, we often need to comment out part of the code for debugging or adjustment. If we manually add comments line by line, this will undoubtedly increase our workload and consume time. As a powerful Python integrated development environment, PyCharm provides the function of quickly annotating code, which greatly improves our development efficiency. This article will share some methods to quickly annotate code in PyCharm and provide specific code examples. one

See all articles