Using comments in php

Comments in PHP are similar to comments that are used in HTML. The PHP comment syntax 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 single line comment

While there is only one type of comment in HTML, PHP has two types. The first type we will discuss is the single line comment. The single line comment tells the interpreter to ignore everything that occurs on that line to the right of the comment. To do a single line comment type "//" or "#" and all text to the right will be ignored by PHP interpreter.

PHP Code:

<?php
echo "Hello World!"; // This will print out Hello World!
echo "<br />You can't see my PHP comments!"; // echo "nothing";
// echo "sssoftaid.com";
# echo "codetpoint.com";
?>

Display:

Hello World!
You can't see my PHP comments!

PHP multiple line comment

Similiar to the HTML comment, the multi-line PHP comment can be used to comment out large blocks of code or writing multiple line comments. The multiple line PHP comment begins with " /* " and ends with " */ ".

PHP Code:

<?php
/* This Echo statement will print out my message to the
the place in which I reside on.*/
echo "Hello World!"; 
/* echo "My name is Shailesh!";
echo "No way! My name is Shailesh PHP Programmer!";
*/
?>

Display:

Hello World!