<?php
class Post
{
private $text;
public function __construct($text)
{
$this->text = $text;
}
public function show()
{
printf('%s' . PHP_EOL, $this->text);
}
}
class SponsoredPost extends Post
{
}
$posts = [];
$posts[0] = new Post('hello');
$posts[1] = new Post('hello again');
$posts[2] = new SponsoredPost('hello hello');
$posts[0]->show();
$posts[1]->show();
$posts[2]->show();