Raczkuje w OOP. Natknąlem się na taki błąd:
Cytat
Warning: Invalid argument supplied for foreach() in /homez.108/micneo/www/test/class.emailer.php on line 43
class.emailer.php
<? // class.emailer.php class Emailer { private $sender; private $recipients; private $subject; private $body; function __construct($sender) { $this->sender = $sender; } public function addRecipients($recipient) { } public function setSubject($subject) { $this->subject = $subject; } public function setBody($body) { $this->body = $body; } public function sendEmail() { foreach ($this->recipients as $recipient) { "From: {$this->sender}r\n"); {$recipient}<br/>"; } } } 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-2' . "r\n"; $headers .= 'From: {$this->sender}' . "r\n"; $headers); {$recipient}<br/>"; } } } ?>
oraz plik emailer.php
<?php include_once("class.emailer.php"); $mailHTML = new HtmlEmailer("adres@mail.pl"); $mailHTML->addRecipients("odbioraca@mail.pl"); $mailHTML->setSubject("temat"); $mailHTML->setBody("test"); $mailHTML->sendHTMLEmail(); ?>
Nie wiem co jest nie tak. Jak się wczesniej bawiłem dziedziczeniem to śmigało (nie wykorzystalem pętli foreach). Nie wiem co źle robie. Prosze o pomoc.
Pozdrawiam!