CKTIS / PHP
Komentáře a dokumentace
// nebo # začíná řádkový komentář, /* a */ ohraničují blok.
Verze: PHP 8.4; repository runtime, production runtime not attested
Syntaxe
// line comment
/* block comment */
/** documentation comment */// nebo # začíná řádkový komentář, /* a / ohraničují blok. Bloky nelze vnořit. Dokumentaci /* před deklarací lze číst reflexí, pokud se komentáře zachovají. V PHP 8 zahajuje #[ atribut.
/** 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]
Pří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ýsledek
[25,true]