In the wonderful world of Java/JSP, you can use this form of commenting:
<%-- 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 in the much less wonderful world of PHP, the only reference to comments I can find are these:
/* multi-line comment */
and these:
// single line comment
But these WON’T comment out chucks of HTML and PHP tags:
/* <? do_something() ?> */
results in /* and */ being rendered to the browser, and do_something() is still called.
Is there an equivalent of the JSP comment shown above in PHP?
Advertisement
Answer
The reason that this will not comment out a block:
/* <? do_something() ?> */
is simply that you are not in php but in html and /* */
is not a valid comment structure in html.
If you had
<?php /* some_php(); ?> and html <?php more_php(); */ ?>
it would work just fine. The php inside the comment block will not be executed and nothing of it will get sent to the browser.
Although it doesn’t work so well on the SO code highlighter…
Just make sure you are in php (after a <?php
tag) when you open your comment section.