mirror of
https://github.com/igorsimdyanov/php8.git
synced 2025-08-01 16:49:53 +00:00
27 lines
510 B
PHP
27 lines
510 B
PHP
<?php
|
|
class Container
|
|
{
|
|
private $title = 'Класс Container';
|
|
protected $id = 1;
|
|
public function anonym()
|
|
{
|
|
return new class($this->title) extends Container
|
|
{
|
|
|
|
private $name;
|
|
|
|
public function __construct($title)
|
|
{
|
|
$this->name = $title;
|
|
}
|
|
|
|
public function print()
|
|
{
|
|
echo "{$this->name} ({$this->id})";
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
(new Container)->anonym()->print();
|