onegative Posted June 13, 2006 Share Posted June 13, 2006 G'day All,I am trying to understand how to define specific environmental variables needed to run a system command from php? I am using the system() to call the command but even though the user account has the environmental variable set, it does not appear to be used when issuing the command from within my php code.Not sure what I am missing and all the searches I have done with regard to defining environmental variables within php code seem vague if not non-existant.Any help would be appreciated and thanks in advance...DannyG Quote Link to comment https://forums.phpfreaks.com/topic/11909-environmental-variables/ Share on other sites More sharing options...
onegative Posted June 13, 2006 Author Share Posted June 13, 2006 OK,I figured it out. You can use the putenv() function to add environmental variables if you are not running php in safe mode. It allows you to do something as follows:[code]putenv('HOME=/opt/app/p1momw1');[/code]This allows the php script to use this environmental each time the script is called. I would assume you could also use an include file if it was needed in multiple pages...Anyway, I am glad...DannyG Quote Link to comment https://forums.phpfreaks.com/topic/11909-environmental-variables/#findComment-45204 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.