note 107421 added to function.getenv
| From: | phpatkeithtylerdotcom | Date: | Wed, 08 Feb 2012 00:51:22 +0000 |
| Subject: | note 107421 added to function.getenv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185902@lists.php.net to get a copy of this message | ||
All of the notes and examples so far have been strictly CGI.
It should not be understated the usefulness of getenv()/putenv() in CLI as well.
You can pass a number of variables to a CLI script via environment variables, either in Unix/Linux
bash/sh with the "VAR='foo'; export $VAR" paradigm, or in Windows with the
"set VAR='foo'" paradigm. (Csh users, you're on your own!)
getenv("VAR") will retrieve that value from the environment.
We have a system by which we include a file full of putenv() statements storing configuration values
that can apply to many different CLI PHP programs. But if we want to override these values, we can
use the shell's (or calling application, such as ant) environment variable setting method to do
so.
This saves us from having to manage an unmanageable amount of one-off configuration changes per
execution via command line arguments; instead we just set the appropriate env var first.
----
Server IP: 208.69.120.55
Probable Submitter: 174.46.204.210
----
Manual Page -- http://www.php.net/manual/en/function.getenv.php
Edit -- https://master.php.net/note/edit/107421
Del: integrated -- https://master.php.net/note/delete/107421/integrated
Del: useless -- https://master.php.net/note/delete/107421/useless
Del: bad code -- https://master.php.net/note/delete/107421/bad+code
Del: spam -- https://master.php.net/note/delete/107421/spam
Del: non-english -- https://master.php.net/note/delete/107421/non-english
Del: in docs -- https://master.php.net/note/delete/107421/in+docs
Del: other reasons-- https://master.php.net/note/delete/107421
Reject -- https://master.php.net/note/reject/107421
Search -- https://master.php.net/manage/user-notes.php