My Account   Contact Us    
  
» HomeProductsSupportDeveloper CommunityCompany
Print Environment Variables
Author: Greg Alton
Category: PHP
Print out environment variables.

Place the following in a file named variables.inc in the current directory.

<?php

// Print Environment Variables
 echo "<b>Environment Variables from $HTTP_ENV_VARS</b><br><br>";
  reset($HTTP_ENV_VARS);
   while (list ($key, $val) = each ($HTTP_ENV_VARS)) {
  print $key . " = " . $val . "<br>";
 }

// Print GET Variables 
 echo "<br>";
 
 echo "<b>GET Variables from $HTTP_GET_VARS</b><br><br>";
  reset($HTTP_GET_VARS);
   while (list ($key, $val) = each ($HTTP_GET_VARS)) {
  print $key . " = " . $val . "<br>";
 }

// Print POST Variables 
 echo "<br>";
 
 echo "<b>POST Variables from $HTTP_POST_VARS</b><br><br>";
  reset($HTTP_POST_VARS);
   while (list ($key, $val) = each ($HTTP_POST_VARS)) {
  print $key . " = " . $val . "<br>";
 }

// Print COOKIE Variables 
 echo "<br>";
 
 echo "<b>COOKIE Variables from $HTTP_COOKIE_VARS</b><br><br>";
  reset($HTTP_COOKIE_VARS);
   while (list ($key, $val) = each ($HTTP_COOKIE_VARS)) {
  print $key . " = " . $val . "<br>";
 }

// Print SESSION Variables
 echo "<br>";
 
 echo "<b>SESSION Variables from $HTTP_SESSION_VARS</b><br><br>";
  reset($HTTP_SESSION_VARS);
   while (list ($key, $val) = each ($HTTP_SESSION_VARS)) {
  print $key . " = " . $val . "<br>";
 }
 
?>

Call the file with the following at any point in your page where you would like the variables output.

<?php
  require("variables.inc");
?>




Content Management Powered by ActivEdit  ActivEdit Browser Based WYSIWYG HTML Editor

More Code Samples

Sign up for our newsletter: | Subscribe with RSS: RSS
© ActivSoftware 1999 to 2005 | Privacy Statement