Re: global env variables not working in php-cgi

From: Date: Mon, 16 Apr 2001 16:12:40 +0000
Subject: Re: global env variables not working in php-cgi
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-48762@lists.php.net to get a copy of this message
Hello. The version is php-4.02 built on Sep 22, 2000. |What version of PHP? I ask because a few test functions aren't available on |older versions of PHP4. | |Try this piece of code: | |$arr = get_defined_vars(); | |print_r($arr); This gave me an error on get_defined_var() so I tried print_r($GLOBALS) and got a ton of output of the form: Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => | /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array (|(if that doesn't work, try print_r($GLOBALS), but be sure to hit the Stop [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS]|button on your browser, because it will print off an infinite list) | => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( )|Now, look at the results. In the main listing, does it list any of the ENV [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS]|variables you are trying to access? | => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( )|If not, page down a bit and look in the HTTP_SERVER_VARS array. Are the ENV [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS]|variables in there? | => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php|My guess is that they probably are. Check phpinfo() again and see what |register_globals is On. That may be your problem... [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF]| => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array (|If none of the variables you seek are in HTTP_SERVER_VARS, then something is [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS]|wrong with the installation of PHP itself. | | => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php )| |-- [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] =>|Plutarck |Should be working on something... /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array (|...but forgot what it was. | [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS]| | => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS]|> => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( )|> I am migrating a site to a new host (westhost.com) and having some [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php [HTTP_GET_VARS]|> issues. PHP was compiled as a cgi instead of a module which is what I => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF] => /test.php|> have always used. This wasn't really an issue until I realized a lot of [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array ( [PHP_SELF]|> my scripts that depended on apaches environment variables ($REQUEST_URI, => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] => Array (|> $HTTP_USER_AGENT, etc.) weren't working. I can write a PERL cgi script [PHP_SELF] => /test.php [HTTP_GET_VARS] => Array ( ) [HTTP_COOKIE_VARS] => Array ( ) [HTTP_SERVER_VARS] => Array ( [PHP_SELF] => /test.php ) [GLOBALS] Something may be amiss with my hosts setup yet I have no idea what that may be. Any suggestions? I have never configured PHP to run as a cgi and have never had trouble getting global server variables. Combine those two and I have no idea how to track this problem down. Many thanks for any/all help. //frank

« previous php.general (#48762) next »