- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- Employee Object ( [name] => Петр [age] => 23 ) Employee Object ( [name] => Валера [age] => 54 ) Меня зовут Петр. Мне 23 года. Меня зовут Валера. Мне 54 года.
<?php
Class Employee
{
public string $name;
public int $age;
public function __construct(string $n, int $a)
{
$this->name = $n;
$this->age = $a;
}
public function getThis()
{
return $this;
}
public function getFullInfo()
{
return 'Меня зовут ' . $this->name . '. Мне ' . $this->age . ' года.' . PHP_EOL;
}
}
$petr = new Employee('Петр', 23);
$valera = new Employee('Валера', 54);
print_r($petr->getThis());
print_r($valera->getThis());
echo $petr->getFullInfo();
echo $valera->getFullInfo();