Comments are generally written in the block of PHP code to describe the functionality of the code. It will help you and others in the future to know what you were trying to do with the PHP code. Comments won’t be displayed within the output.
There are two types of Comments:
- Single Line Comments
- Multi-Line Comments
Single Line Comments
PHP single line comment starts with //
, Get the Code below:
<?php
echo "Hello World!"; // Output "Hello World!"
?>
Multi-Line Comments
PHP multi-line line comment starts with /*
, and ends with */
.
<?php
/* The following line of code
will output the "Hello World!" message */
echo "Hello World!";
?>
Recent Comments