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 'One Final Test' ; # 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 tag does not break out of PHP mode in single-line comments.
<h1>This is an <?php # echo 'simple'; ?> example</h1> <p>The header above will say 'This is an example'.</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 = 'abc';
Use /* and */ This is to comment out a large paragraph, such as
/* $today = 'tomorrow'; */
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!