How to put comments in .php, .html, .css files to declare, remind explanation of code to third party developers, designers or even users which may even includes you, This technique can also be utilise while writing or debugging code by selectively disabling or enabling lines of source code

There are different ways of putting comments per type of file on world wide web.

 
Comments helps developer of code to explain third party developers, designers, users or even to himself in space of time why he used that line of code & what function it performs in that web application.

 
So it is real handy to have that knowledge of how to put comments in your files in PHP, CSS & HTML.

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

 

<!-- put comments here to explain it more -->

 
Comments inside of PHP code look like this:

 

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

 
Or like this:

 

<?php /* This is my special hack.

& It requires a comment that spans multiple lines just to explain! */

my_special_hack();
?>

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

 

/* comment here about what this style does */

 

Note: All above respective mentioned techniques can also be utilise while writing or debugging code by selectively disabling or enabling lines of source code

 
Happy Coding…!!!

 
Thanks & Regards
Mandar Apte

Mandar Apte

This website contains a design articles blog by Mandar Apte. He writes and shares his iOS development, graphic, web, & animation film design experience through articles. Mandar is Mumbai based multi-disciplinary designer with expertise in UI, UX, Logo, Symbol, and Brand Identity design. He is an alumnus of Sir J. J. Institute of Applied Art, Mumbai. He currently runs his studio in the heart of the city of Mumbai.

Leave a Reply

Your email address will not be published. Required fields are marked *