RE: [PHP] Defining Variables to use with a Function

From: Date: Fri, 24 May 2002 18:01:31 +0000
Subject: RE: [PHP] Defining Variables to use with a Function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-99117@lists.php.net to get a copy of this message
You can set a variable in a configuration file containing the email address as normal $to = "my@mail.address"; In the function, use the global statement to bring the variable into the function's scope. Function SetTo($to) { global $to; if (strlen($to)<=0) return $this->Error(1, '"to" too short'); if (strlen($to)>=129) return $this->Error(1, '"to" too long'); $this->mailto[]=$to; return true; } Best Regards, Patrick Lynch. Optip Ltd, Internet & Mobile Development Co. Clare, Ireland. http://www.optip.com/ -----Original Message----- From: chris reeper [mailto:chrisreeper@yahoo.com] Sent: 24 May 2002 18:45 To: php-general@lists.php.net Subject: [PHP] Defining Variables to use with a Function Hi how can i set a variable defining an email address in this function ? Function SetTo($to) { if (strlen($to)<=0) return $this->Error(1, '"to" too short'); if (strlen($to)>=129) return $this->Error(1, '"to" too long'); $this->mailto[]=$to; return true; } -chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#99117) next »