RE: [PHP] Problems with environment variables
| From: | Lawrence dot Sheed at dfait-maeci dot gc dot ca | Date: | Thu, 16 Nov 2000 08:48:39 +0000 |
| Subject: | RE: [PHP] Problems with environment variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-25655@lists.php.net to get a copy of this message | ||
when in a function, if you want to access variables out of the scope of the
function use global.
eg
function dummyfunc(){
global REMOTE_ADDR;
echo "dummyfunc.REMOTE_ADDR==>" . $REMOTE_ADDR . "<br>";
}
-----Original Message-----
From: kod811 [mailto:kod811@bigfoot.com]
Sent: November 16, 2000 04:52 PM
To: php-general@lists.php.net
Subject: [PHP] Problems with environment variables
Hello all,
I've been having problems getting values out of the env vars $HTTP_HOST,
$REMOTE_ADDR, $REMOTE_PORT, etc. I've got the following code to illustrate
my problem:
<?php
function dummyfunc() {
echo "dummyfunc.REMOTE_ADDR==>" . $REMOTE_ADDR . "<br>";
echo "dummyfunc.REMOTE_PORT==>" . $REMOTE_PORT . "<br>";
echo "dummyfunc.REMOTE_ADDR:REMOTE_PORT==>" . $REMOTE_ADDR . ":" .
$REMOTE_PORT . "<br>";
echo "dummyfunc.HTTP_HOST==>" . $HTTP_HOST . "<br>";
}
echo "main.REMOTE_ADDR==>" . $REMOTE_ADDR . "<br>";
echo "main.REMOTE_PORT==>" . $REMOTE_PORT . "<br>";
echo "main.REMOTE_ADDR:REMOTE_PORT==>" . $REMOTE_ADDR . ":" . $REMOTE_PORT
. "<br>";
echo "main.HTTP_HOST==>" . $HTTP_HOST . "<br>";
dummyfunc();
?>
When viewed through a browser, I get the following output:
main.REMOTE_ADDR==>132.232.341.111
main.REMOTE_PORT==>4444
main.REMOTE_ADDR:REMOTE_PORT==>132.232.341.111:4444
main.HTTP_HOST==>server1.blarg.com
dummyfunc.REMOTE_ADDR==>
dummyfunc.REMOTE_PORT==>
dummyfunc.REMOTE_ADDR:REMOTE_PORT==>:
dummyfunc.HTTP_HOST==>
What am I doing wrong? Am I missing something?
Thank you for your response in advance.
kod811
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net