Commenting Your Code (Chapter 4)

Main Lab 4 Page


There are four methods of commenting when one is using PHP. The first is the simple HTML comment, which exists outside PHP, and is encased within these simple comment braces: <!-- ... -->

These types of comments will be visible to the user if they decide to "view source" in their webbrowser. PHP comments, on the other hand, and parsed and ignored before the page even gets to the user's desktop, meaning they're completely invisible to them.

In PHP there are three commenting methods:

  • A single-line comment is prefaced with two forward slashes.
  • A multi-line comment is encased in these simple commenting braces: /* ... */
  • Finally, there's the shell-style comment, which is prefaced by a number sign (#).

The first comment below will be visible to the user, but only if they decide to 'view source'. The three comments that follow it are unavailable to the user, and will remain completely invisible.