CKTIS / PHP
Comentários e documentação
// ou # iniciam comentários de linha e /* e */ delimitam blocos não aninháveis.
Versão: PHP 8.4; repository runtime, production runtime not attested
Sintaxe
// line comment
/* block comment */
/** documentation comment */// ou # iniciam comentários de linha e /* e / delimitam blocos não aninháveis. A documentação /* antes de uma declaração pode ser lida por reflexão se os comentários forem conservados. Em PHP 8 #[ abre um atributo.
/** 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]
Exemplos
<?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")]);
Resultado
[25,true]