reference/info/functions/getenv.xml
1299a9808782769bba9f6a48bf52cb1c68182e78
...
...
@@ -3,22 +3,18 @@
3
3
<refentry xml:id="function.getenv" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
4
4
<refnamediv>
5
5
<refname>getenv</refname>
6
-
<refpurpose>Gets the value of an environment variable</refpurpose>
6
+
<refpurpose>Gets the value of a single or all environment variables</refpurpose>
7
7
</refnamediv>
8
8

9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>string</type><methodname>getenv</methodname>
13
-
<methodparam><type>string</type><parameter>varname</parameter></methodparam>
12
+
<type class="union"><type>string</type><type>array</type><type>false</type></type><methodname>getenv</methodname>
13
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>name</parameter><initializer>&null;</initializer></methodparam>
14
14
<methodparam choice="opt"><type>bool</type><parameter>local_only</parameter><initializer>&false;</initializer></methodparam>
15
15
</methodsynopsis>
16
-
<methodsynopsis>
17
-
<type>array</type><methodname>getenv</methodname>
18
-
<void/>
19
-
</methodsynopsis>
20
16
<para>
21
-
Gets the value of an environment variable.
17
+
Gets the value of a single or all environment variables.
22
18
</para>
23
19
<para>
24
20
You can see a list of all the environmental variables by using
...
...
@@ -33,10 +29,10 @@
33
29
<para>
34
30
<variablelist>
35
31
<varlistentry>
36
-
<term><parameter>varname</parameter></term>
32
+
<term><parameter>name</parameter></term>
37
33
<listitem>
38
34
<para>
39
-
The variable name.
35
+
The variable name as a &string; or &null;.
40
36
</para>
41
37
</listitem>
42
38
</varlistentry>
...
...
@@ -44,7 +40,8 @@
44
40
<term><parameter>local_only</parameter></term>
45
41
<listitem>
46
42
<para>
47
-
Set to true to only return local environment variables (set by the operating system or putenv).
43
+
When set to &true;, only local environment variables are returned, set by the operating system or putenv. It only has
44
+
an effect when <parameter>name</parameter> is a &string;.
48
45
</para>
49
46
</listitem>
50
47
</varlistentry>
...
...
@@ -56,10 +53,10 @@
56
53
&reftitle.returnvalues;
57
54
<para>
58
55
Returns the value of the environment variable
59
-
<parameter>varname</parameter>, or &false; if the environment
60
-
variable <parameter>varname</parameter> does not exist.
61
-
If <parameter>varname</parameter> is omitted, all environment variables are
62
-
returned as associative <type>array</type>.
56
+
<parameter>name</parameter>, or &false; if the environment
57
+
variable <parameter>name</parameter> does not exist.
58
+
If <parameter>name</parameter> is &null;, all environment variables are
59
+
returned as an associative <type>array</type>.
63
60
</para>
64
61
</refsect1>
65
62

...
...
@@ -75,14 +72,20 @@
75
72
</thead>
76
73
<tbody>
77
74
<row>
75
+
<entry>8.0.0</entry>
76
+
<entry>
77
+
The <parameter>name</parameter> is now nullable.
78
+
</entry>
79
+
</row>
80
+
<row>
78
81
<entry>7.1.0</entry>
79
82
<entry>
80
-
The <parameter>varname</parameter> can now be omitted to retrieve an
83
+
The <parameter>name</parameter> can now be omitted to retrieve an
81
84
associative <type>array</type> of all environment variables.
82
85
</entry>
83
86
</row>
84
87
<row>
85
-
<entry>5.5.38, 5.6.24, 7.0.9</entry>
88
+
<entry>7.0.9</entry>
86
89
<entry>
87
90
The <parameter>local_only</parameter> parameter has been added.
88
91
</entry>
...
...
@@ -92,19 +95,6 @@
92
95
</informaltable>
93
96
</refsect1>
94
97

95
-
<refsect1 role="notes">
96
-
&reftitle.notes;
97
-
<warning>
98
-
<para>
99
-
If PHP is running in a SAPI such as Fast CGI, this function will
100
-
always return the value of an environment variable set by the SAPI,
101
-
even if <function>putenv</function> has been used to set a local
102
-
environment variable of the same name. Use the <parameter>local_only</parameter>
103
-
parameter to return the value of locally-set environment variables.
104
-
</para>
105
-
</warning>
106
-
</refsect1>
107
-

108
98
<refsect1 role="examples">
109
99
&reftitle.examples;
110
100
<para>
...
...
@@ -129,6 +119,19 @@ $ip = getenv('REMOTE_ADDR', true) ?: getenv('REMOTE_ADDR')
129
119
</para>
130
120
</refsect1>
131
121

122
+
<refsect1 role="notes">
123
+
&reftitle.notes;
124
+
<warning>
125
+
<para>
126
+
If PHP is running in a SAPI such as Fast CGI, this function will
127
+
always return the value of an environment variable set by the SAPI,
128
+
even if <function>putenv</function> has been used to set a local
129
+
environment variable of the same name. Use the <parameter>local_only</parameter>
130
+
parameter to return the value of locally-set environment variables.
131
+
</para>
132
+
</warning>
133
+
</refsect1>
134
+

132
135
<refsect1 role="seealso">
133
136
&reftitle.seealso;
134
137
<para>
...
...
@@ -141,7 +144,6 @@ $ip = getenv('REMOTE_ADDR', true) ?: getenv('REMOTE_ADDR')
141
144
</refsect1>
142
145

143
146
</refentry>
144
-

145
147
<!-- Keep this comment at the end of the file
146
148
Local variables:
147
149
mode: sgml
148
150