If you are familiar with Magento, esp with setting up multiple websites/stores using .htaccess then you may have encountered variables like: MAGE_RUN_CODE & MAGE_RUN_TYPE. Yes they are the custom environment variables.
In order to set up custom environment variables using .htaccess, try as follows:
RewriteRule ^ - [E=MAGE_RUN_CODE:default]
RewriteRule ^ - [E=MAGE_RUN_TYPE:store]
Where MAGE_RUN_CODE & MAGE_RUN_TYPE are custom environment variables.
and from php you can access this variable as:
echo $_SERVER['MAGE_RUN_CODE']; //prints default
echo $_SERVER['MAGE_RUN_TYPE']; //store
Hope this gave some info about custom environment variables.
Cheers!!