PHP Comments

PHP Comments

A comment in PHP code is a line that is not executed as part of the program. Its only purpose is to be read by someone who is looking at the code.

Comments can be used to:


Single-Line Comments

PHP supports two ways to write single-line comments: // and #.

Example

<?php
// This is a single-line comment

This is also a single-line comment

echo "Comments are invisible!"; ?>


Multi-Line Comments

To comment out multiple lines at once, start the comment with /* and end it with */.

Everything between those markers will be completely ignored by the PHP engine, making it perfect for long explanations or temporarily disabling large blocks of code.

/* This is a multi-line comment block
that spans over multiple lines */