PHP Comments

Comments are used to make your code easier to read and maintain. PHP provides three types of comments:

1. Single-line Comment using //   [Shortcut: Ctrl + /]

<?php
// Print a greeting message
echo "Hello World!";
?>

2. Single-line Comment using # (Old style)   [Shortcut: Manual]

<?php
# This method is less common but still works
echo "Using hash comments!";
?>

3. Multi-line Comment using /* ... */   [Shortcut: Ctrl + Shift + /]

<?php
/*
This function displays a user's profile.
You can customize it to show name, email, and photo.
*/
echo "User Profile";
?>

4. Inline Comment (Next to Code)   [Shortcut: Ctrl + /]

<?php
$price = 100; // Base product price
$tax = 0.15;  // 15% VAT
?>

5. Disable Code Using Comments   [Shortcut: Ctrl + /]

<?php
// echo "This line won't run";
echo "This line will run";
?>

6. Comments for Functions   [Shortcut: Ctrl + Shift + /]

<?php
/*
Function: greetUser
Purpose: Display a greeting message
Input: $name (string)
*/
function greetUser($name) {
  echo "Welcome, $name!";
}
?>