04- PHP Comments

0
520

This tutorial is all about PHP Comments.

One of the best programming practice is using a Comment. A comment is a string code or text within PHP or any programming languages that is not visible during the execution in your web browser. And it provides the feedback to the developers or it temporarily disable the code and the most important thing is that comment serves to give some information about the code.

In PHP, there are two types of Comment. The Single line comment and the Multiple line comment.

PHP comment syntax: Using Single Line Comment
The single line comment only ignores everything to the end of the line or the current block of PHP code. To make a single line comment, you can simply type “//” or “#” and all text right will be disabled by the PHP interpreter.
Example:

  1. <!--?php echo "This is a test sample";//this will output This is a test sample //the next two line of code will echo nothing //echo "This is a Second sample"; #echo "This is third sample"; ?-->

Output:
This is a test sample

PHP comment syntax: Using Multiple line comment
The multiple line comment used to comment large block of code. The multiple line comment in PHP starts with “/*” and ends with “*/”.
Example:

  1. <!--?php echo "This is a test sample";//this will output This is a test sample /*the next two line of code will echo nothing echo "This is a Second sample"; echo "This is third sample"; */ ?-->

Output:
This is a test sample

 

Readers might read also:

Facebook Comments
SHARE
Previous article03- PHP Syntax
Next article05- PHP echo
Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!

LEAVE A REPLY

Please enter your comment!
Please enter your name here