加注釋的方法

PHP 上可以用 C、 C++、 和 Unix shell 的注釋方法。 在注釋號內的內容將被 PHP 解釋器忽略。 比如說 :

<?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
 /* 
    echo "This is a test"; /* This comment will cause a problem */
 */
?>