One of the greatest features in OOP is that you can extend a class and create a completely new object. The new object can retain all the functionality of the parent object from which it is extended or can override. The new object can also introduce some features. Let's extend our Emailer
class and override the sendEmail
function so that it can send HTML mails.
<? class HtmlEmailer extends emailer { public function sendHTMLEmail() { foreach ($this->recipients as $recipient) { $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: {$this->sender}' . "\r\n"; $result = mail($recipient, $this->subject, $this->body, $headers); if ($result) echo "HTML Mail successfully sent to ...