ignace Posted June 3, 2009 Share Posted June 3, 2009 Hi, I have created a .htaccess file with the following line: SetEnv VARIABLE value in my php script i do: define('VARIABLE', getenv('VARIABLE') ? getenv('VARIABLE') : 'default-value'); But this doesn't work it always gives me default-value. I also tried export VARIABLE=value which also doesn't work anyone know how i can get this working on both linux and windows? Quote Link to comment https://forums.phpfreaks.com/topic/160761-solved-setenv-variable-value/ Share on other sites More sharing options...
JonnoTheDev Posted June 3, 2009 Share Posted June 3, 2009 http://uk3.php.net/manual/en/function.putenv.php Quote Link to comment https://forums.phpfreaks.com/topic/160761-solved-setenv-variable-value/#findComment-848467 Share on other sites More sharing options...
ignace Posted June 4, 2009 Author Share Posted June 4, 2009 And how am i supposed to call putenv() in htaccess or my os? I need a solution whereby i can add VARIABLE to my environment variables and that i can use getenv() to retrieve that value so far i haven't been able Quote Link to comment https://forums.phpfreaks.com/topic/160761-solved-setenv-variable-value/#findComment-849106 Share on other sites More sharing options...
JonnoTheDev Posted June 4, 2009 Share Posted June 4, 2009 You don't. If you want to set an environment variable for your php script then you place it within the script. If you want to set a variable for the entire webserver then you should use the httpd.conf file and restart the server. Quote Link to comment https://forums.phpfreaks.com/topic/160761-solved-setenv-variable-value/#findComment-849114 Share on other sites More sharing options...
ignace Posted June 4, 2009 Author Share Posted June 4, 2009 Well i know it is possible because i've seen people do it, they added an environment variable to their os and then launched their script the environment variable was needed to modify the mode (production, development, staging or testing) in which the script was operating and/or it could/couldn't throw errors/exceptions. I was only dumb enough not to ask how they did it as i assumed that just adding it to your environment variable would suffice Quote Link to comment https://forums.phpfreaks.com/topic/160761-solved-setenv-variable-value/#findComment-849235 Share on other sites More sharing options...
JonnoTheDev Posted June 4, 2009 Share Posted June 4, 2009 and/or it could/couldn't throw errors/exceptions This would be achieved in your htaccess using the following: php_flag display_errors off You do not have to set these things in an .htaccess file. You could use a common include file within the application i.e. config.inc.php <?php ini_set('display_errors', 'on'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/160761-solved-setenv-variable-value/#findComment-849281 Share on other sites More sharing options...
ignace Posted June 5, 2009 Author Share Posted June 5, 2009 K found it! modified my variables_order to egpcs added APPLICATION_ENV to my system variables instead of user variables logged off, logged on worked Quote Link to comment https://forums.phpfreaks.com/topic/160761-solved-setenv-variable-value/#findComment-849808 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.