PHP

readonly properties (PHP)

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

Një fushë readonly mund të caktohet vetëm një herë — zakonisht në konstruktor — dhe pastaj s'ndryshon më. Ideale për objekte që thjesht mbajnë të dhëna.

EnglishEN

A readonly property can be set only once — usually in the constructor — and then never changes. Ideal for objects that just hold data.

Si ta mendosh

Si numri i letërnjoftimit: caktohet një herë.

Lexoje në anglisht

Like an ID number: set once.

Shembull kodiphp

<?php
final class Pika {
  public function __construct(public readonly int $x, public readonly int $y) {}
}
$p = new Pika(1, 2); // $p->x = 5;  // Gabim

Terma të lidhur