WissensdatenbankPrüfungszentrum
DEDeutsch
Sprache wählen13

CKTIS / PHP

Kommentare und Dokumentation

// oder # beginnen einen Zeilenkommentar, /* und */ begrenzen einen Block.

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

Syntax

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

// oder # beginnen einen Zeilenkommentar, /* und / begrenzen einen Block. Blöcke sind nicht schachtelbar. Ein /* vor einer Deklaration ist per Reflection lesbar, wenn Kommentare erhalten bleiben. PHP 8 beginnt mit #[ ein 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]

Beispiele

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

Ergebnis

[25,true]

Quellen