CKTIS / PHP
Komentáre a dokumentácia
// alebo # začína riadkový komentár, /* a */ ohraničujú blok.
Verzia: PHP 8.4; repository runtime, production runtime not attested
Syntax
// line comment
/* block comment */
/** documentation comment */// alebo # začína riadkový komentár, /* a / ohraničujú blok. Bloky nemožno vnoriť. Dokumentáciu /* pred deklaráciou možno čítať reflexiou, ak sa komentáre zachovajú. V PHP 8 začína #[ atribút.
/** 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]
Príklady
<?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")]);
Výsledok
[25,true]