Apache – Create an Environment Variable to Use With PHP

Add this in your Apache configuration file:
SetEnv ENVIRONMENT “dev”

In this way, thanks to the SetEnv instruction, we have created some environment variables in Apache that can be used inside our PHP code.
In our PHP script we can access the variable this way:
$env= $_SERVER[’ENVIRONMENT’];

This entry was posted in Apache. Bookmark the permalink.

Leave a Reply