<?php
class A
{
protected $sql = null;
public function setSQL()
{
$this->sql = "SELECT * FROM users WHERE id = 123";
return $this;
}
public function getSQL()
{
return $this->sql;
}
}
class B extends A
{
public function addSQL()
{
$this->sql .= " AND name = 'Alex'";
return $this;
}
}
$a = new A();
$b = new B();
echo $b->setSQL()->addSQL()->getSQL();
$prod = [
'x' => new Phone('Iphone X ', '$1500 ', 'Phone ', 'Apple ', 'A9 ', '1024 ', '1 ', '128gb ', 'Ios '),
'mon' => new Monitor('Abracadabra ', '$1500 ', 'Monitor ', 'DELL ', '24 ', '144ghz ', 'HDMI '),
'mon1' => new Monitor('ROG ', '$1500 ', 'Monitor ', 'ASUS ', '24 ', '144ghz ', 'HDMI ')
];
foreach($prod as $p) $p->show();