Skip to main content
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 */.

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.
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.
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.
Tired of Poor PHP Skills? Fix That With Deep Grasping!Learn More