← 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

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.