PHP Comments

In this lesson, you will learn about the different types of Comments in PHP, their usage, and examples to better understand the topic.


PHP Comments

A comment is simply a text that the PHP engine ignores. It is a programmer-readable description of the source code of a PHP program, and the purpose of the code is described in the comments. Making proper use of comments can simplify code maintenance and speed up bug discovery.

Additionally, it is very beneficial when writing functions so that the code is understandable by others.


Types of comments in PHP

The two types of comments that PHP supports are listed below.

Single line comment

Example

<?php
// Single line comment
# Also Single line comment
?>

Multi-line comment

Example

<?php
/*
Multiple-lines comment block
Multiple-lines comment block
Multiple-lines comment block
*/
?>

This concludes the Comments in PHP lesson. In the next lesson, you will learn about the various arithmetic operations in the PHP Programming Language.