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

怪我咯
Release: 2023-03-10 15:38:02
Original
21296 people have browsed it

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
?>
Copy after login

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 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>
Copy after login

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
  
  */
?>
Copy after login

PHP commentsThere are two types:

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

//$message = &#39;abc&#39;;
Copy after login

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

/*
$today = &#39;tomorrow&#39;;
*/
Copy after login

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!

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!