Date
Sep. 8th, 2024
 
2024年 8月 6日

Post: PHP Primer 016 : 注释

PHP Primer 016 : 注释

Published 12:01 Jan 22, 2012.

Created by @ezra. Categorized in #Programming, and tagged as #PHP.

Source format: Markdown

Table of Content

在 PHP 中支持三种注释风格:

  • // : 双斜杠单行注释,注释内容写在后面,不支持换行

  • # : 井号单行注释,注释内容写在后面,不支持换行

  • /**/ : 多行注释,注释内容中支持换行

举个栗子:

<?php 
    $var = "normal code"; // normal code here
    // example:
    $a = 0;
    $b = 1; # another example
    $c = 2;
    /*
    if ($a == 0) {
        echo "a=0";
    }
    */
    $d = 3;
    $e = 4;
?>

如果在 <?php?> 之外的 HTML 代码中添加注释,应当使用 HTML 的注释语法,即 <COMMENT></COMMENT> 组合或 <!----> 组合。

Pinned Message
HOTODOGO
The Founder and CEO of Infeca Technology.
Developer, Designer, Blogger.
Big fan of Apple, Love of colour.
Feel free to contact me.
反曲点科技创始人和首席执行官。
程序猿、设计师、奇怪的博主。
苹果死忠、热爱色彩斑斓的世界。
如有意向请随时 与我联系