Home  >  Article  >  Backend Development  >  What are the comment methods that cannot be used in php

What are the comment methods that cannot be used in php

下次还敢
下次还敢Original
2024-04-27 10:54:25376browse

Single-line comments (//) and perl-style comments (#!) are not allowed in PHP. Therefore, these two annotation methods cannot be used in PHP.

What are the comment methods that cannot be used in php

Comment methods that cannot be used in PHP

Two comment methods are not allowed in PHP:

1. Single-line comments (//)

In PHP, single-line comments start with double slashes (//). However, the PHP interpreter treats // as a line separator, not a comment separator. Therefore, single-line comments cannot be used in PHP.

2. Perl-style comments (#!)

In Perl, perl-style comments start with #!. This kind of comment has special meaning to the Perl interpreter, but not in PHP. Therefore, perl-style comments cannot be used in PHP.

For example:

The following code is not valid in PHP because it attempts to use a single line comment:

<code>// 这是一个单行注释</code>

The following code is also invalid in PHP, Because it tries to use perl-style comments:

<code>#! 这是一个perl 式注释</code>

The above is the detailed content of What are the comment methods that cannot be used 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