Baza znanjaIzpitno središče
SLSlovenščina
Izberi jezik13

CKTIS / PHP

Komentarji in dokumentacija

// ali # začne vrstični komentar, /* in */ omejujeta blok.

Različica: PHP 8.4; repository runtime, production runtime not attested

Sintaksa

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

// ali # začne vrstični komentar, /* in / omejujeta blok. Blokov ni mogoče gnezditi. Dokumentacijo /* pred deklaracijo bere refleksija, če se komentarji ohranijo. V PHP 8 #[ začne 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]

Primeri

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

Rezultat

[25,true]

Viri