• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Chad Ritchie

Graphic Designer, Front-End Web Developer

  • Blog
    • WordPress
  • Projects
    • Graphic Design
    • Web Projects
  • Photos
  • Services
  • Contact

Understanding Code Comments

July 12, 2013 By Chad Ritchie

Code commenting is the practice of writing short, normally single-line notes throughout your code.

These notes are called comments. They explain how your program works, and your intentions behind it.

Comments don’t have any effect on your program, but they are extremely helpful for others reading your code.

Comments in HTML or PHP pages (outside of the PHP code) look like this:

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

Comments in CSS files look like this:

/* comment here about a style */

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();
?>
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X

Filed Under: Blog

Footer

Chad Ritchie Web & Graphic Design