SyntaxStudy
Sign Up
PHP Beginner 1 min read

PHP Comments

PHP Comments

PHP supports three comment styles. Comments are ignored by the PHP engine.

  • // single line
  • # single line (shell style)
  • /* multi-line */

PHPDoc

Documentation comments use /** ... */ with tags like @param, @return. IDEs and tools read these.

Example
<?php
// Single-line comment

# Also single-line (less common)

/*
 * Multi-line comment
 * Spans multiple lines
 */

/**
 * Adds two numbers.
 *
 * @param int $a First number
 * @param int $b Second number
 * @return int Sum
 */
function add(int $a, int $b): int {
    return $a + $b;
}
?>