FFD - Visit the site
ICMS

12 January 06

Beginner PHP Tutorial 3: Comments

In this short tutorial I will cover:

So…let’s get started.

What are comments?

Comments are a way for coders to explain a section or line of code right inside the source code. Notice that compilers and interpreters ignore comments, so they don’t cause loss of speed, especially with desktop programs since they are compiled before the end user works with them, so the comments are already gone.

Why use comments?

They help other coders to understand what a section/line of code does, without having to figure it out themselves. It also helps you to remember what sections of code do, when you are working on a big project, or improving scripts you wrote previously. If you are working on a big project for wide use then using comments will encourage coders to create mods for your web application, which is great.

How do you use them in php?

Easy, simply start a line with # or //. You can also place comments within /*and*/, which can spread across multiple lines. Here is an example of the three ways:

 <?php
 //simple comment
 # another simple comment
 /* a multiple
  line
  simple
  comment */
 ?>

Well done, you can now use comments in php.