Learn with Yasir
Share Your Feedback

PHP Basics Tutorial – Comments in PHP


Learn how to use single-line and multi-line comments in PHP. This guide explains how to write comments with //, #, and /* */ for better code readability.

In PHP, comments are used to add notes or explanations within the code. These comments are ignored by the PHP interpreter and do not affect the execution of the script. They help programmers document their code, making it easier to understand and maintain. There are two main types of comments in PHP:

1. Single-line Comments:

  • Use // or # for single-line comments.
<?php
// This is a single-line comment
# This is also a single-line comment
?>

2. Multi-line Comments:

  • Use /* */ for multi-line comments.
<?php
/*
This is a multi-line comment
spanning multiple lines
*/
?>

🧠 Practice & Progress

Explore More Topics

PHP Basics

More ...