ID: 21006 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Bogus Bug Type: IIS related Operating System: win 200 server PHP Version: 4.3.0RC3 New Comment:
Some thoughts: a) That error has nothing to do with undefined or "non global" variables. It's a parse error. b) Variables are case sensitive, never write $_Server it's ALWAYS $_SERVER c) A weird character? I really don't think this was ever an error in PHP and has to do with your code only, PHP won't put weird characters in your code. I blame your text editor. Try this test: <?php echo foo(); function foo() { return $_SERVER['HTTP_USER_AGENT']; } ?> What text editor do you use to write code? Previous Comments: ------------------------------------------------------------------------ [2002-12-14 01:49:43] [EMAIL PROTECTED] RC3 seems to have fixed it weird character ahowing up in front of $ ------------------------------------------------------------------------ [2002-12-14 01:26:40] [EMAIL PROTECTED] 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 this bug report at http://bugs.php.net/?id=21006&edit=1