PHP 支持 C,C++ 和(hé) Unix Shell 風(fēng)格(Perl 風(fēng)格)的注釋。例如(rú):
<?php
echo 'This is a test'; // 這(zhè)是單行(xíng) c++ 樣式注釋
/* 這(zhè)是一(yī)條多行(xíng)注釋
另一(yī)行(xíng)也是注釋 */
echo 'This is yet another test';
echo 'One Final Test'; # 這(zhè)是單行(xíng) shell 風(fēng)格的注釋
?>
單行(xíng)注釋僅僅注釋到行(xíng)末或者當前的 PHP 代碼塊,視(shì)乎哪個首先出現。這(zhè)意味着在 // ... ?> 或者 # ... ?> 之後的 HTML 代碼将被顯示出來:?> 跳(tiào)出了(le) PHP 模式并返回了(le) HTML 模式,// 或 # 并不能(néng)影響到這(zhè)一(yī)點。
<h1>This is an <?php # echo 'simple';?> example</h1>
<p>The header above will say 'This is an example'.</p>
C 風(fēng)格的注釋在碰到第一(yī)個 */ 時(shí)結束。要(yào)确保不要(yào)嵌套 C 風(fēng)格的注釋。試圖注釋掉一(yī)大塊代碼時(shí)很(hěn)容易出現該錯誤。
<?php
/*
echo 'This is a test'; /* 這(zhè)個注釋會引發問(wèn)題 */
*/
?>
網站建設開(kāi)發|APP設計開(kāi)發|小程序建設開(kāi)發