PHP 支持 'C','C++' 和 Unix Shell 风格的注释。例如:
<?php echo "This is a test"; // This is a one-line c++ style comment /* This is a multi line comment yet another line of comment */ echo "This is yet another test"; echo "One Final Test"; # This is shell-style style comment ?> |
"单行" 注释仅仅注释到行末或者当前的 PHP 代码块,无论哪个首先出现。
<h1>This is an <?php # echo "simple";?> example.</h1> <p>The header above will say 'This is an example'. |
小心不要嵌套 'C' 风格的注释,当注释大量代码时,可能犯该错误。
"单行" 注释仅仅注释到行末或者当前的 PHP 代码块,无论哪个首先出现。这意味着 // ?> 后面的 HTML 代码将被打印出来,?> 跳出了 PHP 模式并且返回 HTML 模式,而且 // 注释 符并不会影响到模式的转换。