Wednesday, 30 January 2013

PHP Tutorial . Chapter 3 . Comments

Knowing certain commands , implementing them in your code is one thing , but making your code more organised , more readable to others so that when you work in a team , others should have a rough idea of what your variables and member functions are upto . And for that including comments in your code is a very good idea . You don't know who else might be working on your code so it is a very good idea to convey what your program does through comments . C/c++ coders will be happy to know that commenting works the same way in both of them . Others , chillax , grab a cup of coffee and just follow the examples :-

Single Line Comment :-

$a = 5 ;    //This is an example of single line comment.
$b = 6;    #Another example of single line comment

For a single line comment , you have to give two slashes followed by your comment .

Multi-line Comment :-

$c = 9 ; /* This is an example of multi-line comment
                 2nd line....
3rd line ...
and so on ...
........ */
Remember one thing , you cannot nest multi-line comments like :-

$d= "epic-fail"; /* This /* is
not */correct*/

The word "correct" will be interpreted as a part of the code . So be careful !!