|
|
 |
getenv (PHP 3, PHP 4 , PHP 5) getenv -- Gets the value of an environment variable Descriptionstring getenv ( string varname)
Returns the value of the environment variable
varname, or FALSE on an error.
You can see a list of all the environmental variables by using
phpinfo(). You can find out what many of them
mean by taking a look at the CGI
specification, specifically the page on environmental variables.
See also putenv().
sorry at spammed dot nut
12-Jul-1999 10:43
To show a use of getenv("QUERY_STRING")....
suppose you
have a site with frames... the frames create the "interface",
and one frame called "main" has an active document... now,
suppose you made a page.php3 which took an argument "pg" and spit
out the framesets necessary, with "main" frame containing
whatever "pg" is... so now you can bring up any page in your
site with page.php3?pg=test.html
now, take this one step further, and
suppose you want outside links to point to php3 pages which takes
parameters, ON your site... but you still want them to appear in frames,
so what do you do? well, if "ok.php3" was the page you wanted to
show, and it was requested as "ok.php3?some=params&go=here",
then the very thing in the beginning of ok.php3 could be
if
(!isset($inframe)) {
header("Location: http://yoursite/page.php3?pg=".urlencode("inframes=1&").getenv("QUERY_STRING"));
exit;
}
Now... you might ask, how in the world did I come up
with THAT? Well, perhaps it was because I came here not able to remember
which environment variable held the query string...
| |