Variable Scope problem passing function parameters

From: Date: Thu, 18 Dec 2008 19:09:03 +0000
Subject: Variable Scope problem passing function parameters
Groups: php.general 
Request: Send a blank email to php-general+get-284804@lists.php.net to get a copy of this message
I'm new to PHP 5 and classes, but I've done a lot of ActionScript. I'm trying to use PHPMailer inside my own class (a service for AMFPHP). I'm having problems getting the data that'spassed into my class's send() method to the instance of the PHPMailer. Basically, I have this: class EmailAMF { public function send ($from, $to, $subject, $body) {
    require('class.phpmailer.php');
    $phpMail = new PHPMailer();
    $phpMail->From = $from;
    $phpMail->AddAddress($this->to);
    $phpMail->Subject = $subject;
    $phpMail->Body = $body;
    return $phpMail->Send();
} } As far as I can tell, it sends an essentially blank email to nobody (but returns true. If I replace any of my function variables with strings, like this: $phpMail->AddAddress('me@example.com'); the email actually "gets" that data. What am I missing? Thanks, Jim

« previous php.general (#284804) next »