SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 38 | Next

Hasin Hayder

"Object-Oriented Programming with PHP5"

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)
Chapter 2
[ 29 ]
{
$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
{$recipient}
";
}
}
}
?>
As this class extends the Emailer class and introduces a new function,
sendHTMLEmail(), you can still have all the methods from its parent. That means
the following code is fully valid:
include_once("class.htmlemailer.php");
$hm = new HtmlEmailer();
//.... do other things
$hm->sendEmail();
$hm->sendHTMLEmail();
?>
If you want to access any method of the parent class (or you may say superclass)
from which it is derived, you can call using the parent keyword.


Pages:
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6