Lecture # 3 Comments:-

Commenting in PHP

A Comment is a Programmer's Readable Explanation or Annotation in the Source Code of a Program. They are added with the purpose of making the Source Code Easier for Humans to understand, and are generally ignored by Compilers and Interpreters.

Uses

Planning and Reviewing
Code Description
Algorithmic Description
Resource inclusion
Metadata
Debugging
Automatic Documentation Generation
Syntax Extension
Stress Relief





There are two commenting formats in PHP -


1. Single Line Comments
2. Multi Line Comments



Single-line Comment

They are generally used for short Explanations or notes relevant to the local code. Here are the examples of single line Comments.

<?php

     # This is a comment, and
     # This is the second line of the comment 

     // This is a comment too. Each style comments only print 
         "An example with single line comments"; 

?>

Multi-lines Comments

They are generally used to provide pseudo code algorithms and more detailed explanations when necessary. The multi line style of commenting is the same as in C. Here are the example of multi lines comments.

<?php

     /*  This is a Comment with multi line 
          Author : Mohammad Usman 
          Purpose: Multiline Comments Demo 
          Subject: PHP  */ 
     
          print "An example with multi line comments"; 

?>

Comments

Popular posts from this blog

Differences

Uses of PHP

What is PHP?