一起评论HTML和PHP

问题描述:

我有这段代码

I have this code

    <tr>
      <td><?php echo $entry_keyword; ?></td>
      <td><input type="text" name="keyword" value="<?php echo $keyword; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_sort_order; ?></td>
      <td><input name="sort_order" value="<?php echo $sort_order; ?>" size="1" /></td>
    </tr>

我很乐意在一个镜头中发表评论......但是当我尝试时

and i would love to comment both in one shot...but when i try

    <!-- <tr>
      <td><?php echo $entry_keyword; ?></td>
      <td><input type="text" name="keyword" value="<?php echo $keyword; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_sort_order; ?></td>
      <td><input name="sort_order" value="<?php echo $sort_order; ?>" size="1" /></td>
    </tr> -->

页面失败...似乎php没有被注释掉....是吗?一种方法来做到这一点

the page fails...it seems the php is not being commented out....is there a way to do this

不使用HTML注释(它对PHP代码没有影响 - 仍然会被执行),您应该使用PHP注释:

Instead of using HTML comments (which have no effect on PHP code -- which will still be executed), you should use PHP comments :

<?php /*
<tr>
      <td><?php echo $entry_keyword; ?></td>
      <td><input type="text" name="keyword" value="<?php echo $keyword; ?>" /></td>
    </tr>
    <tr>
      <td><?php echo $entry_sort_order; ?></td>
      <td><input name="sort_order" value="<?php echo $sort_order; ?>" size="1" /></td>
    </tr>
*/ ?>





因此,HTML中的PHP代码将不会被执行。并且没有任何(不是HTML,不是PHP,不是它的非执行结果)将被显示。



只需要注意一点:你不能嵌套C风格的评论。 。这意味着评论将在遇到的第一个 * / 结束。


Just one note : you cannot nest C-style comments... which means the comment will end at the first */ encountered.