PHP Comments

Comments in PHP code are simple lines of text which are ignored by the PHP engine. Its only purpose is to make the code more readable. Comments are used to let other programmers understand your code or remind yourself of what you did with PHP while editing your own code.

PHP support single-line and multi-line comments. To write a single-line comment, you can put two slashes (//) or a hash symbol (#) at the beginning of the line.

Example

<?php
// Single line comment using slashes
# Single line comment using hash symbol
echo “Hello World!”;
?>

To write multi-line comments in PHP, start the comment with a slash followed by an asterisk (/*) and end the comment with an asterisk followed by a slash (*/).

Example

<?php
/*
This is a multi-line comment
Another comment line

*/
echo “Hello World!”;
?>