- print_r: documentation ( source)
<?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();