一起评论HTML和PHP [英] Comment out HTML and PHP together

查看:73
本文介绍了一起评论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.

这篇关于一起评论HTML和PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆