← All docs
putenv()
Sets an environment variable, or removes it when the argument has no equals sign.
putenv()
function putenv(string $assignment): bool
Sets an environment variable, or removes it when the argument has no equals sign.
Parameters:
$assignment(string)
Returns: bool
Availability
- Compiled (AOT): supported by the Elephc code generator.
eval()(magician interpreter): supported through a declarative interpreter builtin (crates/elephc-magician/src/interpreter/builtins/network_env/putenv.rs).
Examples:
putenv("APP_ENV=production");
echo getenv("APP_ENV") . "\n";
putenv("APP_ENV");
echo getenv("APP_ENV") === false ? "unset\n" : "still set\n";
Internals
For how putenv is implemented in the compiler, see the internals page.