In the previous tutorial, we learn how to select and use the PHP tags. In this tutorial, we will discuss how to give the best comment in the PHP Script. As with PHP tags, PHP gives we multiple choices for our comments in the PHP Scripts.

Syntax comments in PHP always begins with a special character sequence and all text that appears between the start of the comment and the end will be ignored. PHP’s comments will not be displayed to our visitors. It’s only way to view when we are editing and only useful to PHP programmers. A comment is some part of a script file which the interpreter will ignore it when the script executes. There are two type syntax comments available : single line and multiple line comment.

In the single line comment, interpreter will ignore everything that occurs on that line to the right of the comment. A special character for make single line comment : “//” or “#”, all text to the right will be ignored by PHP interpreter. Single line comment are useful if we have little to say or if we want to add comment in the middle of a block of code.

In the multiple comment, interpreter will ignore everything text that is located between a special character of the multiple line comment. Multiple comment can be used to comment out large blocks of code, begins with special character “/*” and ends with “*/”. For example, see script PHP below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
<?php
 
 
         // Single line comment 
 
 
	/* 
             Multiple comment 
	     All  text that is located between a special character /* and */
	     Will be ignored by interpreter
         */
 
?>

 

There are best style comment in code, we always leave comment at the start of a page or function to describing the purpose of this section. If we want to create automatic document in the our code, so to do, we must start with specific style of comment. There is a specific style of comment that you will often see which starts with a slash-star and then another star, and has the @ symbol in it. This is the syntax understood by PhpDocumentor. We can read more about this at PHPDoc but here’s a fast overview of a function document block:

1
2
3
4
5
6
7
8
9
10
11
12
 
<?php
 
 
        /**
          * tags demonstration
          * @author Mohamad Widodo 
          * @version 5.2.2
          * @copyright Widya Tehnika
          */
 
?>
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • Slashdot
  • Technorati
  • YahooMyWeb