Search notes:

PHP code snippets: getenv()

getenv('xyz') returns the value of the environment variable xyz.
<html>
<head><title>getenv</title></head>
<body>

<table summary='getenv'>

<?php

foreach (array (
   'AUTH_TYPE',
   'CONTENT_LENGTH',
   'CONTENT_TYPE',
   'DOCUMENT_ROOT',
   'GATEWAY_INTERFACE',
   'HTTP_ACCEPT',
   'HTTP_USER_AGENT',
   'PATH_INFO',
   'PATH_TRANSLATED',
   'QUERY_STRING',
   'REMOTE_ADDR',
   'REMOTE_HOST',
   'REMOTE_IDENT',
   'REMOTE_USER',
   'REQUEST_METHOD',
   'SCRIPT_NAME',
   'SERVER_NAME',
   'SERVER_PORT',
   'SERVER_PROTOCOL',
   'SERVER_SOFTWARE',
   'US_ROOTF',          // Set to UniformServer installation root by UniformServer
) as $var) {

  print "<tr><td>$var</td><td>".getenv($var)."</td></tr>";

}

?>
</table>

<p>With the UniformServer, the <code>US_ROOTF</code> variable can for example be used to find the <a href='show_errorlog.html'>error log</a>.

<p><a href='getenv.html?foo=bar&amp;fruit=apple'>Try with QUERY_STRING</a>

<form method="post">
  <input name="foo" value="bar"> 
  <input type="submit" value="Try POST method">
</form>

<p>See also <a href='_SERVER.html'>The $_SERVER array</a>.

</body>
</html>

Github repository about-php, path: /getenv.html

See also

CGI
Other PHP snippets

Index