数组中的 PHP 注释


PHP comment in array?

我试图在 php 函数内的以下代码中注释掉 ~/**********/~ 之间的片段:

       $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>";

有一些困难。我需要逃避一些东西才能让该部分评论掉吗?帮不上什么忙。谢谢。

您要注释的部分是纯 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>";

用于注释<!-- -->

$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

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

    "<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%'">"