⚔️თვისებები და მეთოდები
თვისება, მეთდი და კონსტრუქტორი.
<?php
class Human
{
public string $name; // თვისება
public string $lastName;
public int $age;
// კონსტრუქტორი
function __construct(string $name, string $lastName, int $age){
$this->name = $name;
$this->lastName = $lastName;
$this->age = $age;
}
// მეთოდი
public function printFullName(){
echo $this->name.' '. $this->lastName.' - '.$this->age .' years old.';
}
}
// object 1
$quentin= new Human('Quentin','Tarantino',58);
// object 2
$samuel = new Human('Samuel', 'L. Jackson', 73);
სტატიკური მეთოდები და თვისებები
Last updated