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

php – 需要将代码注释放在heredoc中

发布时间:2020-12-13 18:28:01 所属栏目:PHP教程 来源:网络整理
导读:好吧,我似乎无法在我的foo.php文件中的heredoc块中添加注释: echo _HEREDOC_FOO // okay this comment was intended to explain the code below but it // is showing up on the web page HTML sent to the browser form action="foo.php" method="post" in
好吧,我似乎无法在我的foo.php文件中的heredoc块中添加注释:
echo <<<_HEREDOC_FOO

       // okay this comment was intended to explain the code below but it
       // is showing up on the web page HTML sent to the browser

      <form action="foo.php" method="post">
      <input type="submit" value="DELETE RECORD" /></form>

_HEREDOC_FOO;

该表单是否有效,确定(顺便说一下上面的表单代码是高度截断的
为了我的问题,这里).

但是当时的评论(好吧这个评论是……布拉等等)
也出现在浏览器中.它显示在
浏览器如上所述:

// okay this comment was intended to explain the code below but it
// is showing up on the web page HTML sent to the browser

关于评论划分的排列我尝试过:

// <--  
// -->

和….

<-- //
--> //

两种情况都失败,允许我在heredoc内发表评论.

那么我怎么能在我的heredocs中评论我的代码呢?

这是设计的.一旦你成为你的heredoc一切你输入直到你结束它被视为一个长字符串的一部分.你最好的选择是打破你的HEREDOC,发表你的评论,然后开始一个新的回声线
echo <<<_HEREDOC_FOO
    text text text
<<<_HEREDOC_FOO;
//Comments
echo <<<_HEREDOC_FOO
    text text text
<<<_HEREDOC_FOO;

正如其他人提到的那样,您可以进行HTML注释,但查看源代码的任何人都可以看到这些注释

(编辑:李大同)

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

    推荐文章
      热点阅读