Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any benefit in using PHP comments over HTML comments in HTML code? [closed]

Tags:

comments

html

php

I heard someone say that there is, so I was wondering.

HTML comment:

<!-- Comment goes here. --> 

PHP comment:

<?php // Comment goes here. ?> 
like image 469
Emanuil Rusev Avatar asked Aug 09 '11 07:08

Emanuil Rusev


People also ask

Do HTML comments affect performance?

What are the negatives of HTML comments? worsens the UX - even not visible, the HTML comments are part of the DOM tree and increase the number of DOM elements. This, in turn, affects the quickness and responsiveness, also leads to slower CSS selectors and DOM manipulation.

What is the best approach to write an HTML comment?

This element is used to add a comment to an HTML document. An HTML comment begins with <! –– and the comment closes with ––> . HTML comments are visible to anyone that views the page source code, but are not rendered when the HTML document is rendered by a browser.


2 Answers

Unlike HTML comments, PHP comments don't show up in the final output. That is often desirable, as comments are usually internal notes that are none of anybody's business.

like image 110
Pekka Avatar answered Sep 21 '22 04:09

Pekka


PHP comments will not be visible in the source on the client, where HTML comments will. So the question is: do you want the comment to be readable by the end user?

like image 31
Wesley van Opdorp Avatar answered Sep 23 '22 04:09

Wesley van Opdorp