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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1740101836, '18.191.165.197', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/web/php/snippets/getenv(96): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78