The PHP comment starts with a special character sequence and all text that appears between the start of the comment and the end will be ignored.
PHP comments main purpose is to give information about the code to the programmers who works along with you. Commenting will help other programmers to understand how your code, it will be useful to you, when you need to edit your own code.
There are two types of commenting
The single line comment tells the interpreter to ignore every thing that occurs on that line to the right of the comment. To do a single line comment type “ // ” or “ # ” and all text right to it will be ignored by PHP interpreter.
Above Script will display
Copy and paste above script in to editor, save it in Document root directory and run it in localhost to see how comments work
Comment Block:
multi line comments can be used to comment out large blocks of code or writing multiple line comment. The comment block start with “ /* ” and ends with “ */ ”
Above code will outputs
below line to browser
PHP comments main purpose is to give information about the code to the programmers who works along with you. Commenting will help other programmers to understand how your code, it will be useful to you, when you need to edit your own code.
There are two types of commenting
- Single line comment
- Comment Block with multiple lines
The single line comment tells the interpreter to ignore every thing that occurs on that line to the right of the comment. To do a single line comment type “ // ” or “ # ” and all text right to it will be ignored by PHP interpreter.
1: <?php
2:
3: //this a single line comment
4:
5: echo "PHP Comments";
6:
7: #this is another type of single line comment
8:
9: ?>
Above Script will display
PHP Comments
Copy and paste above script in to editor, save it in Document root directory and run it in localhost to see how comments work
Comment Block:
multi line comments can be used to comment out large blocks of code or writing multiple line comment. The comment block start with “ /* ” and ends with “ */ ”
1: <?php
2:
3: /* This is
4: a comment
5: block
6: */
7:
8: echo "Comment Block";
9: ?>
below line to browser
Comment Block
No comments:
Post a Comment