Issue
I'm trying to set up a enviroment variable in my website.
The idea is to creat a $env='test';
or $env='production';
and all the other PHP files, check this var to see in which env they are.
The solution that I will work now is creating a session in the index file. But I dont feel confortable with this solution.
Solution
The best way to do it is to set your environnements variables inside your... environnement.
If you use Apache, you can add this inside your virtual host configuration (or .htaccess):
SetEnv MYAPP_ENV value
Then, inside your PHP:
$_SERVER['MYAPP_ENV']
There is SetEnv equivalent for all the web servers you can find.
Answered By - Damien Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.