Skip to content
Advertisement

PHP Comment Tag

In the wonderful world of Java/JSP, you can use this form of commenting:

JavaScript

In in the much less wonderful world of PHP, the only reference to comments I can find are these:

JavaScript

and these:

JavaScript

But these WON’T comment out chucks of HTML and PHP tags:

JavaScript

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:

JavaScript

is simply that you are not in php but in html and /* */ is not a valid comment structure in html.

If you had

JavaScript

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.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement