【问题标题】:PHP comment in array?数组中的PHP注释?
【发布时间】:2016-04-21 19:38:27
【问题描述】:

我正在尝试在 php 函数内部的以下代码中注释掉 ~/**********/~ 之间的 sn-p:

       $photobody[]="<tr><td colspan=\"".$cols."\">
        <table width=\"100%\" border=\"0\">
        <tr><td width=\"33%\">
        <div align=\"left\" class=\"caption\">".$prev."</div></td>
        <td width=\"33%\">                         
    ~/***** <div align=\"center\" class=\"caption\">Photos 
        <strong>".($photonum-(($rows*$cols)-1))."</strong> to 
        <strong>".$endnum."</strong> of 
        <strong>".count($photos)."</strong>
    <br />".$photopage."</div> ****/~ 
        </td><td width=\"33%\">
        <div align=\"right\" class=\"caption\">".$next."</div></td></tr></table></td></tr>";

有一些困难。有什么我需要逃避才能让该部分注释掉的东西吗?帮助不大。谢谢。

【问题讨论】:

标签: php arrays comments


【解决方案1】:

您要评论的部分是纯 HTML 类型。因此,您需要将 HTML 注释如图所示:-

$photobody[]="<tr><td colspan=\"".$cols."\">
    <table width=\"100%\" border=\"0\">
    <tr><td width=\"33%\">
    <div align=\"left\" class=\"caption\">".$prev."</div></td>
    <td width=\"33%\">                         
<!-- <div align=\"center\" class=\"caption\">Photos 
    <strong>".($photonum-(($rows*$cols)-1))."</strong> to 
    <strong>".$endnum."</strong> of 
    <strong>".count($photos)."</strong>
<br />".$photopage."</div> --> 
    </td><td width=\"33%\">
    <div align=\"right\" class=\"caption\">".$next."</div></td></tr></table></td></tr>";

【讨论】:

    【解决方案2】:

    评论用&lt;!-- --&gt;

    $photobody[]="<tr><td colspan=\"".$cols."\">
            <table width=\"100%\" border=\"0\">
            <tr><td width=\"33%\">
            <div align=\"left\" class=\"caption\">".$prev."</div></td>
            <td width=\"33%\">                         
      <!--<div align=\"center\" class=\"caption\">Photos 
            <strong>".($photonum-(($rows*$cols)-1))."</strong> to 
            <strong>".$endnum."</strong> of 
            <strong>".count($photos)."</strong>
        <br />".$photopage."</div> -->
            </td><td width=\"33%\">
            <div align=\"right\" class=\"caption\">".$next."</div></td></tr></table></td></tr
    

    【讨论】:

      【解决方案3】:

      您应该用额外的" 关闭前一个字符串,以便/* 之后的文本成为注释:

          "<td width=\"33%\">"                         
          /***** <div align=\"center\" class=\"caption\">Photos 
          <strong>".($photonum-(($rows*$cols)-1))."</strong> to 
          <strong>".$endnum."</strong> of 
          <strong>".count($photos)."</strong>
      <br />".$photopage."</div> ****/
          "</td><td width=\"33%\">"
      

      【讨论】:

        猜你喜欢
        • 2011-02-12
        • 2020-02-18
        • 2010-11-21
        • 2019-01-16
        • 2010-12-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多