加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP评论标签

发布时间:2020-12-13 21:54:07 所属栏目:PHP教程 来源:网络整理
导读:在 Java / JSP的精彩世界中,您可以使用以下形式的注释: %-- anything in here is ignored and does not get sent to the client it can span multiple lines and is useful for commenting out blocks of JSP,including tags and HTML: c:if test="${some.c
在 Java / JSP的精彩世界中,您可以使用以下形式的注释:

<%-- anything in here is ignored and does not get sent to the client 
     it can span multiple lines and is useful for commenting out blocks
     of JSP,including tags and HTML:
     <c:if test="${some.condition}">
       <p>All this is inside the comment</p>
     </c:if>
     <!-- this HTML comment is itself commented out of the JSP so will not be sent to the client --!>
--%>
<!-- but this is just an HTML comment and WILL be sent to the client -->

在PHP不太精彩的世界中,我能找到的唯一的评论参考是:

/*
  multi-line comment
*/

还有这些:

// single line comment

但是这些不会注释掉HTML和PHP标签:

/*
 <? do_something() ?>
*/

导致/ *和* /呈现给浏览器,仍然调用do_something().

是否有相当于PHP上面显示的JSP注释?

解决方法

这不会注释掉块的原因:

/*
 <? do_something() ?>
*/

只是你不是在PHP但在html和/ * * /不是HTML中的有效评论结构.

如果你有

<?php
/*
some_php();
?>
and html
<?php
more_php();
*/
?>

它会工作得很好.注释块中的php将不会被执行,并且它不会被发送到浏览器.

虽然它在SO代码荧光笔上不能很好地工作……

打开评论部分时,请确保您使用的是php(在<?php标记之后).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读