PHP text comments

In the beautiful Java / JSP world, you can use this comment form:

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

      

In the much less wonderful PHP world, the only comment reference I can find is this:

/*
  multi-line comment
*/

      

and they:

// single line comment

      

But they DO NOT INCLUDE the HTML and PHP tag patrons:

/*
 <? do_something() ?>
*/

      

causes / * and * / to show up in the browser while do_something () is still called.

Is there an equivalent to the JSP comment shown above in PHP?

+3


source to share


1 answer


Reason this will not comment out the block:

/*
 <? do_something() ?>
*/

      

just that you are not in php but in html and is /* */

not a valid comment structure in html.

If you have



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

      

everything will be fine. Php inside the comment block will not be executed and nothing from it will be sent to the browser.

Although it doesn't work that well on the SO code shortcut ...

Just make sure you are in php (after the tag <?php

) when you open your comment.

+7


source







All Articles