KennisbankExamencentrum
NL · NLNederlands (Nederland)
Taal kiezen13

CKTIS / PHP

Commentaar en documentatie

// of # begint regelcommentaar en /* en */ begrenzen een blok.

Versie: PHP 8.4; repository runtime, production runtime not attested

Syntax

// line comment
/* block comment */
/** documentation comment */

// of # begint regelcommentaar en /* en / begrenzen een blok. Blokken zijn niet nestbaar. Een /* vóór een declaratie is via reflectie leesbaar als commentaar behouden blijft. PHP 8 begint met #[ een attribuut.

/** 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]

Voorbeelden

<?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")]);

Resultaat

[25,true]

Bronnen