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 19 | Next

Hasin Hayder

"Object-Oriented Programming with PHP5"

Procedural Programming
[ 14 ]
public function setSubject($subject)
{
$this->subject = $subject;
}
public function setBody($body)
{
$this->body = $body;
}
public function sendEmail()
{
foreach ($this->recipients as $recipient)
{
$result = mail($recipient, $this->subject, $this->body,
"From: {$this->sender}\r\n");
if ($result) echo "Mail successfully sent to
{$recipient}
";
}
}
}
?>
The above object contains four private properties and three accessor methods and
finally one more method to dispose the email to recipients. So how we are going to
use it in our PHP code? Let's see below:
$emailer = new emailer("hasin@pageflakes.com"); //construcion
$emailer->addRecipients("hasin@somewherein.net"); //accessing methods
// and passing some data
$emailer->setSubject("Just a Test");
$emailer->setBody("Hi Hasin, How are you?");
$emailer->sendEmail();
?>
I am sure that the above code snippet is much more self explanatory and readable.
If you follow proper conventions, you can make your code easy to manage and
maintain. Wordpress developers use a motto on their site www.wordpress.org
which is "Coding is poetry". Coding is exactly a poem; if you just know how to
write it.


Pages:
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6