Home  >  Article  >  Backend Development  >  How many ways are there to comment out code in PHP? What are they?

How many ways are there to comment out code in PHP? What are they?

怪我咯
怪我咯Original
2018-05-18 10:08:4721230browse

HP supports C, C++ and Unix shell-style (Perl-style) annotations. For example:

<?php
     echo  "This is a test" ;  // This is a one-line c++ style comment
    
     echo  "This is yet another test" ;
    echo  &#39;One Final Test&#39; ;  # This is a one-line shell-style comment
?>

A single-line comment only comments to the end of the line or to the current PHP code block, whichever comes first. This means that the HTML code after // ... ?> or # ... ?> will be displayed: ?> jumps out of PHP mode and returns to HTML mode, // or # does not affect at this point. If the asp_tags configuration option is enabled, its behavior is the same as // %> or # %> . However, the 2cacc6d41bbb37262a98f745aa00fbf0 tag does not break out of PHP mode in single-line comments.

<h1>This is an <?php  # echo &#39;simple&#39;; ?> example</h1>
<p>The header above will say &#39;This is an  example&#39;.</p>

C-style comments end when the first */ is encountered. Be sure not to nest C-style comments. This error can easily occur when trying to comment out a large chunk of code.

<?php
  
  */
?>

PHP commentsThere are two types:

Use double slashes// This is to comment out a line of code, such as

//$message = &#39;abc&#39;;

Use /* and */ This is to comment out a large paragraph, such as

/*
$today = &#39;tomorrow&#39;;
*/

The above is the detailed content of How many ways are there to comment out code in PHP? What are they?. 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