PHPHelp with CGI Enviroment

2002 July 27
by MeanDean

<php > is not my native language. I speak is as about as fluently as I speak German or Spanish - two languages I studied, and can read, but heaven help you if I need to speak it. Mostly its a vocabulary thing. Not speaking in these various tongues, I tend to forget the vocabulary and syntax.

So to with <php >

Which is why I was so glad to find the following page to remind me on how to Access the CGI Enviroment variables … appropriately names Basics of Accessing the CGI Enviroment.

Actually the entire site is a pretty good resource if you ask me - though if you must ask in a language other than English, make sure you speak slowly and clearly.

1 Comment leave one →
2002 July 28

I don’t know why people insist on using getenv() for variables that are already available to you.

Why do I use getenv() instead of looking into the GLOBALS array for these values? Because anyone can spoof those values in the globals array. We cannot trust these same values when they come from the GLOBALS array, but getenv() retrieves the values directly from the environment. Many of these values are important to maintaining security on the web, such as REMOTE_HOST (for access to user’s IP address) or PATH_INFO (sometimes carrying crucial information to scripts).

Yeah, I guess… just use $_SERVER, $_ENV, or $HTTP_ENV_VARS, which has always been available. Does getenv involve a system call?

Leave A Comment

You must be logged in to post a comment.