<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Sets the value of an environment variable</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.phpversion.html">phpversion</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.restore-include-path.html">restore_include_path</a></div> <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.putenv" class="refentry"> <div class="refnamediv"> <h1 class="refname">putenv</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">putenv</span> — <span class="dc-title">Sets the value of an environment variable</span></p> </div> <div class="refsect1 description" id="refsect1-function.putenv-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><strong>putenv</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$setting</code></span> )</div> <p class="para rdfs-comment"> Adds <em><code class="parameter">setting</code></em> 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. </p> <p class="para"> Setting certain environment variables may be a potential security breach. The <em>safe_mode_allowed_env_vars</em> directive contains a comma-delimited list of prefixes. In Safe Mode, the user may only alter environment variables whose names begin with the prefixes supplied by this directive. By default, users will only be able to set environment variables that begin with <em>PHP_</em> (e.g. <em>PHP_FOO=BAR</em>). Note: if this directive is empty, PHP will let the user modify ANY environment variable! </p> <p class="para"> The <em>safe_mode_protected_env_vars</em> directive contains a comma-delimited list of environment variables, that the end user won't be able to change using <span class="function"><strong>putenv()</strong></span>. These variables will be protected even if <em>safe_mode_allowed_env_vars</em> is set to allow to change them. </p> </div> <div class="refsect1 parameters" id="refsect1-function.putenv-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">setting</code></em></span> <dd> <p class="para"> The setting, like <em>"FOO=BAR"</em> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.putenv-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-function.putenv-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-517"> <p><strong>Example #1 Setting an environment variable</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />putenv</span><span style="color: #007700">(</span><span style="color: #DD0000">"UNIQID=</span><span style="color: #0000BB">$uniqid</span><span style="color: #DD0000">"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.putenv-notes"> <h3 class="title">Notes</h3> <div class="warning"><strong class="warning">Warning</strong> <p class="para"> The <em>safe_mode_allowed_env_vars</em> and <em>safe_mode_protected_env_vars</em> directives only take effect when <a href="features.safe-mode.html" class="link">safe_mode</a> is enabled. </p> </div> </div> <div class="refsect1 seealso" id="refsect1-function.putenv-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.getenv.html" class="function" rel="rdfs-seeAlso">getenv()</a> - Gets the value of an environment variable</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.phpversion.html">phpversion</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.restore-include-path.html">restore_include_path</a></div> <div class="up"><a href="ref.info.html">PHP Options/Info Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>