From: [EMAIL PROTECTED] Operating system: win 200 server PHP version: 4.3.0RC3 PHP Bug Type: IIS related Bug description: $_Server variables are not global
On my IIS Server, now running 4.3.0RC3 ( i just installed and tested it, started writing issue with RC2), $_Server variables are not global, they don't work inside functions specifically $agent = $_SERVER["HTTP_USER_AGENT"]; I hear that *nix machines do not have this issue. The following does not work, there is no variable set for the user agent and i get an error. <?php whatever(); function whatever() { $agent = $_SERVER["HTTP_USER_AGENT"]; } ?> Parse error: parse error, unexpected T_VARIABLE in c:\ inetpub\wwwroot\admin\index.php on line 26 PHP Parse error: parse error, unexpected T_VARIABLE in c:\ inetpub\wwwroot\admin\index.php on line 26 Basically the variable is not set. This does work outside the function however <?php $agent = $_SERVER["HTTP_USER_AGENT"]; ?> (i coded this to explain issue more simply, originally got help at http://www.webmasterworld.com/forum13/1766.htm which has more specific details, example code and the like) $_SERVER["HTTP_USER_AGENT"]; is global in scope but is not accessable in my installation inside a function. I now use define to pass variable down to my function and avoid any more issues personally. I have a feeling it has to do with my using release candidate 2 but do not wish to test with previous versions of php at this time. This seems like an IIS quirk as the forum moderator seemed not to have this issue and agreed $_SERVER variables are global in scope, as is my understanding from was what i read in the manual. info from my phpinfo() PHP Version 4.3.0RC2 System Windows NT localhost 5.0 build 2195 Build Date Nov 27 2002 21:11:38 Server API CGI/FastCGI register globals is also on for the time being, (seems like this is always asked) -- Edit bug report at http://bugs.php.net/?id=21006&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=21006&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=21006&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=21006&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=21006&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=21006&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=21006&r=support Expected behavior: http://bugs.php.net/fix.php?id=21006&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=21006&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=21006&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=21006&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21006&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=21006&r=dst IIS Stability: http://bugs.php.net/fix.php?id=21006&r=isapi