PHP

static, self & parent (PHP)

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

ShpjegimiSQ

Fushat dhe metodat static i përkasin klasës, jo objekteve — i thërret me Klasa::metoda(). Brenda klasës, self:: i referohet klasës aktuale, parent:: prindit, dhe static:: klasës që u thirr vërtet (e rëndësishme me trashëgiminë).

EnglishEN

Static properties and methods belong to the class, not objects — you call them with Class::method(). Inside the class, self:: refers to the current class, parent:: to the parent, and static:: to the class actually called (important with inheritance).

Si ta mendosh

Si tabela e rezultatit në stadium: një e vetme për të gjithë.

Lexoje në anglisht

Like the stadium scoreboard: one for everyone.

Shembull kodiphp

class Numerues {
  private static int $n = 0;
  public static function rrit(): int { return ++self::$n; }
}
echo Numerues::rrit();

Terma të lidhur