uTools-Manuals/docs/php/putenv.html
2019-04-08 23:22:26 +08:00

111 lines
4.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>设置环境变量的值</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.putenv" class="refentry">
<div class="refnamediv">
<h1 class="refname">putenv</h1>
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">putenv</span> &mdash; <span class="dc-title">设置环境变量的值</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.putenv-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>putenv</strong></span>
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$setting</code></span>
) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
添加 <code class="parameter">setting</code> 到服务器环境变量。
环境变量仅存活于当前请求期间。
在请求结束时环境会恢复到初始状态。
</p>
<p class="para">
设置特定的环境变量也有可能是一个潜在的安全漏洞。
<em>safe_mode_allowed_env_vars</em> 包含了一个以逗号分隔的前缀列表。
在安全模式下,用户可以仅能修改用该指令设定的前缀名称的指令。
默认情况下,用户仅能够修改以 <em>PHP_</em> 开头的环境变量(例如 <em>PHP_FOO=BAR</em>)。
注意如果此指令是空的PHP允许用户设定任意环境变量
</p>
<p class="para">
<em>safe_mode_protected_env_vars</em> 指令包含了逗号分隔的环境变量列表,使用户最终无法通过 <span class="function"><strong>putenv()</strong></span> 修改。
即使 <em>safe_mode_allowed_env_vars</em> 设置允许修改,这些变量也会被保护。
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.putenv-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">setting</code></dt>
<dd>
<p class="para">
设置,例如 <em>&quot;FOO=BAR&quot;</em>
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.putenv-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功时返回 <strong><code>TRUE</code></strong> 或者在失败时返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.putenv-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-530">
<p><strong>Example #1 设置一个环境变量</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?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">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 notes" id="refsect1-function.putenv-notes">
<h3 class="title">注释</h3>
<div class="warning"><strong class="warning">Warning</strong>
<p class="para">
The <em>safe_mode_allowed_env_vars</em>
<em>safe_mode_protected_env_vars</em> 指令仅仅在启用<a href="features.safe_mode.html" class="link">安全模式</a>时有效。
</p>
</div>
</div>
<div class="refsect1 seealso" id="refsect1-function.putenv-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="getenv.html" class="function" rel="rdfs-seeAlso">getenv()</a> - 获取一个环境变量的值</span></li>
<li class="member"><span class="function"><a href="apache_setenv.html" class="function" rel="rdfs-seeAlso">apache_setenv()</a> - 设置 Apache 子进程环境变量</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>