RE: [PHP] can't access a GET variable on function?
| From: | Chris | Date: | Tue, 16 Dec 2003 05:35:18 +0000 |
| Subject: | RE: [PHP] can't access a GET variable on function? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172775@lists.php.net to get a copy of this message | ||
$emailto is in the global scope, so it's not accessible like that.
You can do it one of three ways:
$emailto = $_GET['EmailTO'];
function wtemp_mainbody() {
global $emailto;
print "Contact (";
echo $emailto;
print ") Info";
}
or
$emailto = $_GET['EmailTO'];
function wtemp_mainbody() {
print "Contact (";
echo $GLOBALS['emailto'];
print ") Info";
}
or (recommended)
function wtemp_mainbody() {
print "Contact (";
echo $_GET['EmailTO'];
print ") Info";
}
-----Original Message-----
From: Louie Miranda [mailto:louie@axishift.ath.cx]
Sent: Monday, December 15, 2003 8:32 PM
To: php-general@lists.php.net
Subject: [PHP] can't access a GET variable on function?
$emailto = $_GET['EmailTO'];
function wtemp_mainbody() {
print "Contact (";
echo "$emailto";
print ") Info";
}
Why can't i display a GET variable from a function? Or should i registered
it on global session?
-- -
Louie Miranda
http://www.axishift.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php