PHP comments can be used to describe any line of code so that other developers can understand the code easily. It can also be used to hide any code. PHP supports single line and multi line comments. These comments are similar to C/C++ and Perl style (Unix shell style) comments.
PHP Single Line Comments
There are two ways to use single line comments in PHP.
- // (C++ style single line comment)
- # (Unix Shell style single line comment)
PHP Multi Line Comments
In PHP, we can comment on multiple lines also. To do so, we need to enclose all lines within /* */. Let’s see a simple example of PHP multiple line comment.
<?php
/*
Anything placed
on the browser;
*/
echo “Welcome to PHP multi line comment”;
?>