PHP supports three types of comments. Two comments are single line and one is multi-line. The code below shows the three types of comments available in PHP, followed by a single line of PHP code.
<?php // PHP single line comment 1 # PHP single line comment 2 /* PHP multi-line comment */ echo "<p>Hello, world!</p>"; ?>
A PHP single line comment can start with a double forward slash // or with a hash character #. A PHP multi-line comment starts with a forward-slash and asterisk /* and ends with a asterisk and forward slash */.
HTML and CSS Comments
<!-- HTML comment -->
/* CSS comment */
Using Comments in Code
As with all programming languages, comments are notes about the code that are human readable. Comments are always ignored by the compiler or interpreter.
In PHP scripts, comments are never sent to the web browser. They always remain in the script on the server.