Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

putenv

Description

The putenv of Options / Information for PHP sets the value of an environment variable.

Syntax

putenv(string $assignment): bool

Parameters

assignment

The setting

Return

Returns true on success or false on failure.

Examples

1 · assignment

<?

$assignment = "MY_LOC_ENV_VAR=my local environment variable";

$return = putenv($assignment);

var_export($return);

?>
true

2 · getenv

<?

$assignment = "MY_LOC_ENV_VAR=my local environment variable";

putenv($assignment);

echo getenv("MY_LOC_ENV_VAR");

?>
my local environment variable

3 · $_ENV

<?

$_ENV["MY_LOC_ENV_VAR"] = "\$_ENV does not assign to putenv";

$assignment = "MY_LOC_ENV_VAR=putenv does not assign to \$_ENV";

putenv($assignment);

echo $_ENV["MY_LOC_ENV_VAR"] . PHP_EOL;
echo getenv("MY_LOC_ENV_VAR");

?>
$_ENV does not assign to putenv
putenv does not assign to $_ENV
HomeMenu