Comments in PHP
Comments are used to make code more readable and to explain what the code is doing. PHP supports three types of comments:
🔸 1. Single-line Comments
You can use either // or # to comment a single line:
<?php
// This is a single-line comment
# This is also a single-line comment
echo "Hello World!";
?>
🔸 2. Multi-line Comments
Use /* ... */ to span comments across multiple lines:
<?php
/* This is a
multi-line comment
used to describe a block of code */
echo "Welcome to PHP!";
?>
🔸 Best Practices
- Use comments to explain the “why”, not just the “what”.
- Keep comments up to date when you modify code.
- Don't overuse comments for obvious code.


