Home  >  Article  >  Backend Development  >  What are the comment symbols not allowed in PHP?

What are the comment symbols not allowed in PHP?

藏色散人
藏色散人Original
2021-11-22 10:32:333916browse

The comment symbol not allowed in PHP is "quote"; there are two types of comments in PHP, namely single-line comments and multi-line comments. There are two ways to declare single-line comments, namely using "# ” and backslash “//”, while multi-line comments use /* */ symbols.

What are the comment symbols not allowed in PHP?

#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.

What are the comment symbols not allowed by PHP?

The comment symbols not allowed by PHP are D and '.

A, //
B,
#C, /* */
D, '

There are two types of comments in PHP, which are single lines. Comments and multiline comments.

1. Single-line comments

Each line must be marked with a separate comment, which is called a single-line comment. It is used for brief description. There are two ways to declare a single-line comment, using "#" and backslash "//".

The sample code is as follows:

<?php
    #这是第一行注释
    echo "PHP中文网<br>";
    //这是第二行注释
    echo "//m.sbmmt.com";
    // echo "PHP 注释";
?>

In the above code example, the second line uses "#" to define a comment, and the fourth and sixth lines use "// ” defines an annotation.

The running results are as follows:

PHP中文网
//m.sbmmt.com

Tip: The most widely used single-line comment is to use double slashes "//" to define the comment.

2. Multi-line comments

Multi-line comments are used to comment on multi-line content, and are often used for comments on multi-line text. The content of the comment needs to be contained in (/* and */), starting with "/*" and ending with "*/".

Tip: Multi-line comments cannot be nested within each other.

The sample code is as follows:

<?php
    /*
        这是一个多行注释
        输出网站名称及链接地址
    */
    echo "PHP中文网<br>";
    echo "//m.sbmmt.com";
    /* echo "PHP 注释"; */
?>

The running results are as follows:

//m.sbmmt.com

Multi-line comments are often used by developers to introduce the functions and parameters of a function or method. In addition, it should be noted that multi-line comments are composed of two tags, "/*" and "*/". It will not work if you ignore either one.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What are the comment symbols not allowed in PHP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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