Environment Variables

You can retrieve individual environment variables from within your PHP program using:


Of course to use that call you need to know what the fieldname is for the environment variable that you want. If you want to retrieve all of the environment variables then you can adapt the following code:

while (list ($key, $val) = each ($_ENV))
echo "$key : $val<br />";}

That code outputs the complete list of all of the environment variables into your web page. If instead you want to process the variables within your page you just need to replace the echo statement with your required code for processing each individual variable.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow