Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt

Use this file to discover all available pages before exploring further.

A PHP multi-line comment is a lexical construct that instructs the PHP parser to ignore a designated block of text spanning one or more lines. Inheriting its syntax from C, the comment is evaluated during the tokenization phase and stripped from the compiled opcode before execution. The comment block is initiated with the opening delimiter /* and terminated by the first occurrence of the closing delimiter */.
<?php
/*
    This is a standard multi-line comment.
    The PHP engine ignores all text, variables, 
    and expressions within these delimiters.
*/
$x = 10;
?>

Technical Characteristics

Inline Masking Despite the “multi-line” designation, this construct can be utilized inline to mask specific segments of an expression without commenting out the entire line.
<?php
$total = 100 + /* 50 + */ 25; // The parser evaluates this as: $total = 100 + 25;
?>
Nesting Limitations PHP multi-line comments cannot be nested. The lexical scanner does not track the depth of opening delimiters; it simply terminates the comment block at the very first */ sequence it encounters. Attempting to nest these comments will expose the remainder of the outer comment to the parser, resulting in a Parse error.
<?php
/*
    Initiating outer comment block.
    
    /* 
       Initiating inner comment block.
    */ 
    
    The parser resumes execution here, treating this text as PHP code, 
    which triggers a syntax error.
*/
?>
DocBlock Distinction While structurally similar, a block starting with /** (two asterisks) is recognized as a DocBlock comment. The PHP lexer explicitly distinguishes DocBlocks from standard multi-line comments by assigning them the T_DOC_COMMENT token instead of the standard T_COMMENT token. This engine-level distinction allows the parser to attach DocBlocks to the Abstract Syntax Tree (AST), making their metadata and type hints accessible to the Reflection API and static analysis tools.
<?php
/**
 * This is a DocBlock comment.
 * Tokenized as T_DOC_COMMENT and attached to the AST.
 */
?>
Master PHP with Deep Grasping Methodology!Learn More