I have seen a lot written about keeping hardcoded sensitive information(API key strings, database passwords) as Environment variables for security. I am a bit new to this concept and while I've seen a lot for rails, not so much on the PHP side.
Even PHP FOG uses this type of setup when creating the initial mysql DB information for a user.
I really don't understand where this is set however and how it is retrieved using any particular php webpage/application. I am really looking at this from the perspective of something like keeping my transaction email API keys and other information safe and usable across multiple pages.
For example, if I just create a config.php file and put it in my site root, is that really any different than calling on the key directly within my code? Where should the environment variables be set and what is the most efficient way in calling them? I'm also curious how this differs from SESSION variables?
Note: I am running a LAMP stack with Nginx paired.
Update 1: One of these users tends to think against using environment variables and just in "non-public" files but I really don't see how this is much different.
Update 2: Found this article as well which seems to make some general sense from a Windows perspective (assuming for *nix need to change the php include path?). Again though, what is the benefit in this rather than just hard coding the API Key directly into the PHP script anyway?