CKTIS / PHP
Comments and documentation
Use // or # for a line comment and /* ... */ for a block.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
// line comment
/* block comment */
/** documentation comment */Use // or # for a line comment and /* ... / for a block. Block comments cannot nest. A documentation comment beginning with /* immediately before a declaration can be read through reflection when comments are retained. PHP 8 also uses #[ to introduce an attribute.
/** Unit price in cents. */
function unitPrice():int { /* in cents */ return 25; } // no output here
$doc=(new ReflectionFunction("unitPrice"))->getDocComment(); echo json_encode([unitPrice(),str_contains($doc,"cents")]);
[25,true]
Examples
<?php
/** Unit price in cents. */
function unitPrice():int { /* in cents */ return 25; } // no output here
$doc=(new ReflectionFunction("unitPrice"))->getDocComment(); echo json_encode([unitPrice(),str_contains($doc,"cents")]);
Result
[25,true]