I know I can set an environment variable using
putenv("ENV_FOO=SOMETHING");
and get the value via:
getenv("ENV_FOO");
If the variable isn't set, getenv("ENV_FOO")
will return false
.
I have a feature set that may be set via an environment variable, and I wanted to unit test the behavior when the variable is set or not set.
Yet once export the variable on my dev machine in bash via
export ENV_FOO=something`
it breaks my unit test, as I cannot unset the environment variable using php for the scope of the test.
I tried putenv("ENV_FOO=");
yet this will return in an empty string ""
, not in an unset environment variable for the current shell session.
Is there a way to unset an environment variable for the current shell session, or do I have to change the way I test for the existence of the variable?