Forum Moderators: coopster

Message Too Old, No Replies

questions about refering to global variables

         

scratch

6:29 am on Dec 11, 2002 (gmt 0)

10+ Year Member



Well i am back here again after again not being able to figure something out. I've copied and researched as much as i can and this time i am stumped. Seems the whole area of accessing constant variables is moving faster than my manual and any of the tutorials. Everyone seems to want "register globals" to be on in everything that i've looked at so it is hard to find valid advice. $_SERVER['PHP_SELF'] is straight from the current manual and it does not work. Everything i've tried causes an error so far. Adding {} around the whole thing, using none, single and double quotes around the parameter.

This is in my php info script
PHP Version 4.3.0RC2
Windows NT localhost 5.0 build 2195
register_globals = on (am trying to code as if it's off as recommended)
_SERVER["HTTP_USER_AGENT"] equals Mozilla/4.0 (compatible; MSIE 5.22; Mac_PowerPC)
using iis on windows 2000

This is some of the stuff i've tried, i also have tried the deprecated versions that are no longer used, but it does no better.
$request = $_Server[PHP_SELF];
$host = $_Server['SERVER_NAME'];
$address =  $_SERVER[REQUEST_URI];
$agent = {$_SERVER['HTTP_USER_AGENT']};
$agent = $_SERVER["HTTP_USER_AGENT"];
$agent = $HTTP_USER_AGENT;

How should i refer to these variables. Is there IIS specific syntax or something new to 4.3. Is it a bug in 4.3 that i am using. I want it to work with globals turned off.

scratch

7:02 am on Dec 12, 2002 (gmt 0)

10+ Year Member



question answered

I used phpinfo() to list all variables
then i copied the server variables section and put $ in front of each one. I left the values as comments as a future reference. Now at least i know exactly what all my variables are.

it seems that $_server variables are not of global scope no matter what the manual says, i was trying to access them in a function i am setting up for logging. Now i have a bunch of define() constructs so i can access this stuff from inside anything without a bunch of fuss.

$agent = $_SERVER["HTTP_USER_AGENT"];

was the working line, which definitely does not work in a function.

Is this how it is on the unix, linux side as well or is this just an iis quirk.

Another hurdle in learning php overcome, on to the next hill

jatar_k

4:59 pm on Dec 12, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I must say I don't remember having that problem and I only work with *nix servers so I guess it's an iis quirk.