Forum und email

註解

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 程式碼內,視何者先出現。這表示 // ?> 後的 HTML 碼將會被輸出、?> 就跳出 PHP 模式,而 // 則不會影響到模式的轉變。

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

在使用 C 式的註釋時,千萬別將一個 C 式註釋放在另一個裡面。這在註釋大段文字時經常發生。

<?php
 
/* 
    echo "This is a test"; /* This comment will cause a problem */
 
*/
?>