Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<phpversionrestore_include_path>
^PHP Options/Info FunctionsLast updated: Mon, 26 Oct 2026

putenv

(PHP 4, PHP 5, PHP 7, PHP 8)

putenv — Sets the value of an environment variable

Description

function putenv(string $assignment): bool

Adds assignment to the server environment. The environment variable will only exist for the duration of the current request. At the end of the request the environment is restored to its original state.

Parameters

assignment

The setting, like "FOO=BAR"

Return Values

Returns true on success or false on failure.

Examples

Example #1 Setting an environment variable

<?php
putenv("UNIQID=$uniqid");
?>

See Also

  • getenv() - Gets the value of a single or all environment variables
  • apache_setenv() - Set an Apache subprocess_env variable


<phpversionrestore_include_path>
^PHP Options/Info FunctionsLast updated: Mon, 26 Oct 2026