Comments – PHP, HTML, CSS, JavaScript & ASP

It’s always a good idea to add comments within your code. They won’t improve your visibility to search engines, nor will they be helpful to visitors, but they will help you keep track of how your code works.

What Are Comments?

Comments simply allow you to add notes to your PHP, HTML, CSS etc. They are especially useful when it comes to complex areas of code – giving you a quick reference point and clearer understanding of ‘what goes where’ when revisiting a file.

How Visible Are Comments?

Comments won’t be visible to your visitors. HTML and CSS comments can only be seen if your visitor views your source code via their browser. PHP and ASP comments are totally invisible and can’t be viewed by a browser as they are server-side.

HTML Comments

<!– This is an example of HTML Comments –>This is a comment in it’s simplest form.

<!– 
Line one.
Line two.
–>
 Comments split onto multiple lines.

CSS Comments

/* Css Comment */ Standard CSS comment

/*
Line one.
Line two.
*/
Comments split onto multiple lines.

PHP Comments

// A PHP comment  Standard PHP comment for a single line – minimum 1 forward slash.

# You can also use a hash.

/*
Line 1
Line 2
*/
Multi-line PHP comments.

Javascript Comments

// A JavaScript comment  Standard JavaScript comment for a single line – minimum 1 forward slash.

# You can also use a hash.

/*
Line 1
Line 2
*/
Multi-line JavaScript comments.

ASP Comments

‘ Standard ASP Comment.