CKTIS / PHP
Commentaires et documentation
// ou # ouvrent un commentaire de ligne et /* et */ délimitent un bloc.
Version : PHP 8.4; repository runtime, production runtime not attested
Syntaxe
// line comment
/* block comment */
/** documentation comment */// ou # ouvrent un commentaire de ligne et /* et / délimitent un bloc. Les blocs ne s’imbriquent pas. Une documentation /* avant une déclaration est lisible par réflexion si elle est conservée. En PHP 8 #[ ouvre un attribut.
/** 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]
Exemples
<?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")]);
Résultat
[25,true]