I love the salt water evaporates in Zend Framework. I'm able to know which atmosphere I am presently using by checking APPLICATION_ENV constant during my controller.

<VirtualHost *:80>

        SetEnv APPLICATION_ENV "development"

    # Directory

But regrettably I can not use ZF during my current project. How do i take a look atmosphere variable during my PHP code?

Since SetEnv set's the worthiness to Apache's atmosphere, you will get it with

  • [cde] — Have an Apache subprocess_env variable

or simply

  • [cde] — Will get the need for an atmosphere variable

Should you take a look at apache_getenv inside a ZF project, you will notice ZF uses getenv:


An frequently use alternative is always to browse the Hostname from PHP and define the continual accordingly:


By doing this, it's not necessary to depend around the atmosphere setting whatsoever.

[cde] defines an atmosphere variable.

Once it has been set (in both your Apache's configuration, or in the system level), read its value while using [cde] function :

// Define application environment
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? 
                                  getenv('APPLICATION_ENV') : 

For example, if you are using this inside your if(!defined('APPLICATION_ENV')) { if(FALSE === stripos($_SERVER['SERVER_NAME']), 'www.example.com') { define(APPLICATION_ENV, 'development'); } else { define(APPLICATION_ENV, 'production'); } } file :


This can be used part of PHP code :


And you will get :

echo getenv('APPLICATION_ENV');