How do you put comments in .php, .html, and .css files to declare? Remind third-party developers and designers of the code’s explanation.

Different ways of putting comments per file type on the World Wide Web exist.

Comments help the code developer explain quickly to third-party developers, designers, users, or even himself why he used that line of code and what function it performs in that web application.

So it is convenient to know how to put comments in your files in PHP, CSS & HTML.

Here is an example of how you will put comments in ‘HTML’ & ‘PHP’ pages (outside of the PHP code) & it will look like this:

<!-- comment here about what is going on -->

Comments inside of PHP code look like this:

<?php the_excerpt(); // Show excerpt and not full post content ?>

Or like this:

<?php /* This is my special hack.
         It's so special it requires a comment that spans multiple lines! */

my_special_hack();
?>

Here is an example of how you will put comments in CSS files & it will look like this:

/* comment here about a style */

Note:
All the techniques mentioned above can also be utilised while writing or debugging code by selectively turning lines of source code on or off.

Happy Coding…

Thanks & Regards
Mandar Apte

Published by Mandar Apte

Mandar is a Mumbai-based multi-disciplinary designer with UX/UI, Logo, Symbol, and Brand Identity design expertise. He currently runs his Mudrkashar Linguistic Apple iPhone, iPad, and Mac app business in the heart of Mumbai city.

Leave a comment

Leave a Reply