PHP - Interfaces and Traits
Given these interfaces and classes:
What is the output of this code?
interface Logger { public function log(string $msg); }
interface Notifier { public function notify(string $msg); }
class System implements Logger, Notifier {
private array $logs = [];
public function log(string $msg) { $this->logs[] = $msg; }
public function notify(string $msg) { echo "Notify: $msg\n"; }
public function getLogs(): array { return $this->logs; }
}
$sys = new System();
$sys->log('Start');
$sys->notify('Alert');
$sys->log('End');
print_r($sys->getLogs());What is the output of this code?
