PHP Comments

Basically PHP supports 'C', 'C++' and Unix shell-style (Perl style) comments. PHP has two types of comment. The first type 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.

Single line comment

To do a single line comment type "//" or "#" and all text to the right will be ignored by PHP interpreter.

Comments in PHP can be used for several purposes, a very interesting one being that you can generate API documentation directly from them by using PHPDocumentor (https://www.phpdoc.org/)

PHP Single Line Comment Example

This will produce following result

Notice that all of our echo statements were not evaluated because we commented them out with the single line comment. This type of line commenting is often used for quick notes about complex and confusing code or to temporarily remove a line of PHP code.

PHP Multi Line Comment

The multi-line PHP comment is similar to 'C', can be used to comment out large blocks of code or writing multiple line comments. This is begins with " /* " and ends with " */ ".

PHP Multi Line Comments Example

This will produce following result

Notice that all of the text statements inside "/*" and "*/" were not evaluated because we commented them out with the multi-line comment. This type of line commenting is often used for detailed explanation of something that should require.