Retrieves the environment variable passed as an argument.
getenv(variable_name
)
$v = getenv("PATH");
Table 3.84. Arguments and Return Values for getenv()
Argument Type | Return Type | Description |
---|---|---|
String | String | The contents of the environment variable, if the environment variable exists, otherwise returns no value. |
This function does not throw any exceptions.
Sets an environment variable to a value.
setenv(key_string, value_string
)
setenv("PATH", "/bin:/usr/bin");
Table 3.85. Arguments and Return Values for setenv()
Argument Type | Return Type | Description |
---|---|---|
String, String | n/a | Sets the environment variable to a string value (the value is converted to a string if necessary). |
This function does not throw any exceptions.
Unsets an environment variable.
unsetenv(key_string
)
unsetenv("PATH");
Table 3.86. Arguments and Return Values for unsetenv()
Argument Type | Return Type | Description |
---|---|---|
String | n/a | Unsets the environment variable given by the string passed. |
This function does not throw any exceptions.
This function is only supported on systems where the C library support for unsetenv() is present.