Type Here to Get Search Results !

Lesson 7: Comment your scripts

As you may have noticed, PHP scripts can easily look confusing. In this lesson, we cover why comments are important and how to insert them into your scripts.

Why is it important to comment your scripts?

When you are coding, you are writing commands to a server/computer and need to use a highly formal language that may not clearly reflect your thoughts when making the script.

Therefore, it can be difficult for others (or yourself) to understand how the script is structured, and thus hard to identify and correct errors in the script.

Comments can be used to write short explanatory text in the script. The server completely ignores the comments, and the comments do not affect the actual functionality of the script.

In the business world, it is often a requirement that scripts and programming are commented, otherwise it would be too risky for a company to take over a system in which it would be too difficult to find and correct errors.

How do you insert comments?

It is quite easy to insert a comment. You simply start the comment with a double slash: "//".
Take a look at this example from lesson 5, now with comments:




For the sake of the example, we have included many extra comments, so it should be clear that you are far better off debugging a script with comments than without.

Therefore, remember to comment your scripts!

Post a Comment

2 Comments
  1. This post is invaluable. How can I find out more?

    ReplyDelete
  2. I have read so many articles concerning the blogger lovers except
    this post is actually a nice piece of writing, keep it up.

    ReplyDelete
* Please Don't Spam Here. All the Comments are Reviewed by Admin.