language/predefined/variables/server.xml
a6d209f4ff71ccba3f1255902827f5df3e092ff9
...
...
@@ -1,46 +1,43 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3

4
-
<phpdoc:varentry xmlns:phpdoc="http://php.net/ns/phpdoc" xml:id="reserved.variables.server" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
4
+
<refentry role="variable" xml:id="reserved.variables.server" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
5
<refnamediv>
6
6
<refname>$_SERVER</refname>
7
-
<refname>$HTTP_SERVER_VARS [removed]</refname>
8
7
<refpurpose>Server and execution environment information</refpurpose>
9
8
</refnamediv>
10
9
11
10
<refsect1 role="description">
12
11
&reftitle.description;
13
12
<para>
14
-
<varname>$_SERVER</varname> is an array containing information
15
-
such as headers, paths, and script locations. The entries in this
16
-
array are created by the web server. There is no guarantee that
17
-
every web server will provide any of these; servers may omit some,
18
-
or provide others not listed here. That said, a large number of
19
-
these variables are accounted for in the <link
20
-
xlink:href="&url.rfc;3875">CGI/1.1 specification</link>, so you should
21
-
be able to expect those.
13
+
<varname>$_SERVER</varname> is an &array; containing information
14
+
such as headers, paths, and script locations.
15
+
The entries in this array are created by the web server, therefore there
16
+
is no guarantee that every web server will provide any of these;
17
+
servers may omit some, or provide others not listed here.
18
+
However, most of these variables are accounted for in the
19
+
<link xlink:href="&url.rfc;3875">CGI/1.1 specification</link>,
20
+
and are likely to be defined.
21
+
</para>
22
+
<note>
23
+
<simpara>
24
+
When running PHP on the <link linkend="features.commandline">command line</link>
25
+
most of these entries will not be available or have any meaning.
26
+
</simpara>
27
+
</note>
28
+
<para>
29
+
In addition to the elements listed below, PHP will create additional
30
+
elements with values from request headers. These entries will be named
31
+
<literal>HTTP_</literal> followed by the header name,
32
+
capitalized and with underscores instead of hyphens.
33
+
For example, the <literal>Accept-Language</literal> header would be
34
+
available as <code>$_SERVER['HTTP_ACCEPT_LANGUAGE']</code>.
22
35
</para>
23
-

24
-
<simpara>
25
-
<varname>$HTTP_SERVER_VARS</varname> contains the same initial
26
-
information, but is not a <link linkend="language.variables.superglobals">superglobal</link>.
27
-
(Note that <varname>$HTTP_SERVER_VARS</varname> and <varname>$_SERVER</varname>
28
-
are different variables and that PHP handles them as such). Also note that long arrays
29
-
were removed since PHP 5.4.0 so <varname>$HTTP_SERVER_VARS</varname> doesn't exist
30
-
anymore.
31
-
</simpara>
32
36
</refsect1>
33
37

34
38
<refsect1 role="indices">
35
39
&reftitle.indices;
36
40

37
-
<simpara>
38
-
You may or may not find any of the following elements in
39
-
<varname>$_SERVER</varname>. Note that few, if any, of these will be
40
-
available (or indeed have any meaning) if running PHP on the
41
-
<link linkend="features.commandline">command line</link>.
42
-
</simpara>
43
-

44
41
<para>
45
42
<variablelist>
46
43
<varlistentry>
...
...
@@ -58,7 +55,7 @@
58
55
</simpara>
59
56
<simpara>
60
57
If PHP is running as a command-line processor this variable contains
61
-
the script name since PHP 4.3.0. Previously it was not available.
58
+
the script name.
62
59
</simpara>
63
60
</listitem>
64
61
</varlistentry>
...
...
@@ -90,7 +87,7 @@
90
87
<listitem>
91
88
<simpara>
92
89
What revision of the CGI specification the server is using;
93
-
i.e. '<literal>CGI/1.1</literal>'.
90
+
e.g. <literal>'CGI/1.1'</literal>.
94
91
</simpara>
95
92
</listitem>
96
93
</varlistentry>
...
...
@@ -113,6 +110,14 @@
113
110
executing. If the script is running on a virtual host, this
114
111
will be the value defined for that virtual host.
115
112
</simpara>
113
+
<note>
114
+
<simpara>
115
+
Under Apache 2, <literal>UseCanonicalName = On</literal> and
116
+
<literal>ServerName</literal> must be set. Otherwise, this value
117
+
reflects the hostname supplied by the client, which can be spoofed.
118
+
It is not safe to rely on this value in security-dependent contexts.
119
+
</simpara>
120
+
</note>
116
121
</listitem>
117
122
</varlistentry>
118
123

...
...
@@ -131,7 +136,7 @@
131
136
<listitem>
132
137
<simpara>
133
138
Name and revision of the information protocol via which the
134
-
page was requested; i.e. '<literal>HTTP/1.0</literal>';
139
+
page was requested; e.g. <literal>'HTTP/1.0'</literal>;
135
140
</simpara>
136
141
</listitem>
137
142
</varlistentry>
...
...
@@ -140,8 +145,8 @@
140
145
<term>'<varname>REQUEST_METHOD</varname>'</term>
141
146
<listitem>
142
147
<simpara>
143
-
Which request method was used to access the page; i.e. '<literal>GET</literal>',
144
-
'<literal>HEAD</literal>', '<literal>POST</literal>', '<literal>PUT</literal>'.
148
+
Which request method was used to access the page; e.g. <literal>'GET'</literal>,
149
+
<literal>'HEAD'</literal>, <literal>'POST'</literal>, <literal>'PUT'</literal>.
145
150
</simpara>
146
151
<note>
147
152
<para>
...
...
@@ -157,7 +162,7 @@
157
162
<term>'<varname>REQUEST_TIME</varname>'</term>
158
163
<listitem>
159
164
<simpara>
160
-
The timestamp of the start of the request. Available since PHP 5.1.0.
165
+
The timestamp of the start of the request.
161
166
</simpara>
162
167
</listitem>
163
168
</varlistentry>
...
...
@@ -167,7 +172,6 @@
167
172
<listitem>
168
173
<simpara>
169
174
The timestamp of the start of the request, with microsecond precision.
170
-
Available since PHP 5.4.0.
171
175
</simpara>
172
176
</listitem>
173
177
</varlistentry>
...
...
@@ -192,109 +196,12 @@
192
196
</varlistentry>
193
197

194
198
<varlistentry>
195
-
<term>'<varname>HTTP_ACCEPT</varname>'</term>
196
-
<listitem>
197
-
<simpara>
198
-
Contents of the <literal>Accept:</literal> header from the
199
-
current request, if there is one.
200
-
</simpara>
201
-
</listitem>
202
-
</varlistentry>
203
-

204
-
<varlistentry>
205
-
<term>'<varname>HTTP_ACCEPT_CHARSET</varname>'</term>
206
-
<listitem>
207
-
<simpara>
208
-
Contents of the <literal>Accept-Charset:</literal> header
209
-
from the current request, if there is one. Example:
210
-
'<literal>iso-8859-1,*,utf-8</literal>'.
211
-
</simpara>
212
-
</listitem>
213
-
</varlistentry>
214
-

215
-
<varlistentry>
216
-
<term>'<varname>HTTP_ACCEPT_ENCODING</varname>'</term>
217
-
<listitem>
218
-
<simpara>
219
-
Contents of the <literal>Accept-Encoding:</literal> header
220
-
from the current request, if there is one. Example: '<literal>gzip</literal>'.
221
-
</simpara>
222
-
</listitem>
223
-
</varlistentry>
224
-
225
-
<varlistentry>
226
-
<term>'<varname>HTTP_ACCEPT_LANGUAGE</varname>'</term>
227
-
<listitem>
228
-
<simpara>
229
-
Contents of the <literal>Accept-Language:</literal> header
230
-
from the current request, if there is one. Example: '<literal>en</literal>'.
231
-
</simpara>
232
-
</listitem>
233
-
</varlistentry>
234
-
235
-
<varlistentry>
236
-
<term>'<varname>HTTP_CONNECTION</varname>'</term>
237
-
<listitem>
238
-
<simpara>
239
-
Contents of the <literal>Connection:</literal> header from
240
-
the current request, if there is one. Example: '<literal>Keep-Alive</literal>'.
241
-
</simpara>
242
-
</listitem>
243
-
</varlistentry>
244
-

245
-
<varlistentry>
246
-
<term>'<varname>HTTP_HOST</varname>'</term>
247
-
<listitem>
248
-
<simpara>
249
-
Contents of the <literal>Host:</literal> header from the
250
-
current request, if there is one.
251
-
</simpara>
252
-
</listitem>
253
-
</varlistentry>
254
-

255
-
<varlistentry>
256
-
<term>'<varname>HTTP_REFERER</varname>'</term>
257
-
<listitem>
258
-
<simpara>
259
-
The address of the page (if any) which referred the user
260
-
agent to the current page. This is set by the user agent. Not
261
-
all user agents will set this, and some provide the ability
262
-
to modify <varname>HTTP_REFERER</varname> as a feature. In
263
-
short, it cannot really be trusted.
264
-
</simpara>
265
-
</listitem>
266
-
</varlistentry>
267
-

268
-
<varlistentry>
269
-
<term>'<varname>HTTP_USER_AGENT</varname>'</term>
270
-
<listitem>
271
-
<simpara>
272
-
Contents of the <literal>User-Agent:</literal> header from
273
-
the current request, if there is one. This is a string
274
-
denoting the user agent being which is accessing the page. A
275
-
typical example is: <computeroutput>Mozilla/4.5 [en] (X11; U;
276
-
Linux 2.2.9 i586)</computeroutput>. Among other things, you
277
-
can use this value with <function>get_browser</function> to
278
-
tailor your page's output to the capabilities of the user
279
-
agent.
280
-
</simpara>
281
-
</listitem>
282
-
</varlistentry>
283
-

284
-
<varlistentry>
285
199
<term>'<varname>HTTPS</varname>'</term>
286
200
<listitem>
287
201
<simpara>
288
202
Set to a non-empty value if the script was queried through the HTTPS
289
203
protocol.
290
204
</simpara>
291
-
<note>
292
-
<simpara>
293
-
Note that when using ISAPI with IIS, the value will be
294
-
<literal>off</literal> if the request was not made through the HTTPS
295
-
protocol.
296
-
</simpara>
297
-
</note>
298
205
</listitem>
299
206
</varlistentry>
300
207

...
...
@@ -313,14 +220,14 @@
313
220
<listitem>
314
221
<simpara>
315
222
The Host name from which the user is viewing the current
316
-
page. The reverse dns lookup is based off the
223
+
page. The reverse dns lookup is based on the
317
224
<varname>REMOTE_ADDR</varname> of the user.
318
225
</simpara>
319
226
<note>
320
227
<simpara>
321
-
Your web server must be configured to create this variable. For
322
-
example in Apache you'll need <literal>HostnameLookups On</literal>
323
-
inside &httpd.conf; for it to exist. See also
228
+
The web server must be configured to create this variable.
229
+
For example in Apache <literal>HostnameLookups On</literal> must be
230
+
set inside &httpd.conf; for it to exist. See also
324
231
<function>gethostbyaddr</function>.
325
232
</simpara>
326
233
</note>
...
...
@@ -390,16 +297,16 @@
390
297
<listitem>
391
298
<simpara>
392
299
The port on the server machine being used by the web server
393
-
for communication. For default setups, this will be '<literal>80</literal>';
300
+
for communication. For default setups, this will be <literal>'80'</literal>;
394
301
using SSL, for instance, will change this to whatever your
395
302
defined secure HTTP port is.
396
303
</simpara>
397
304
<note>
398
305
<simpara>
399
-
Under the Apache 2, you must set <literal>UseCanonicalName = On</literal>,
400
-
as well as <literal>UseCanonicalPhysicalPort = On</literal> in order to
401
-
get the physical (real) port, otherwise, this value can be spoofed and it
402
-
may or may not return the physical port value.
306
+
Under Apache 2, <literal>UseCanonicalName = On</literal>, as well
307
+
as <literal>UseCanonicalPhysicalPort = On</literal> must be set in
308
+
order to get the physical (real) port, otherwise, this value can be
309
+
spoofed, and it may or may not return the physical port value.
403
310
It is not safe to rely on this value in security-dependent contexts.
404
311
</simpara>
405
312
</note>
...
...
@@ -426,16 +333,6 @@
426
333
</simpara>
427
334
<note>
428
335
<simpara>
429
-
As of PHP 4.3.2, <envar>PATH_TRANSLATED</envar> is no longer set
430
-
implicitly under the Apache 2 <acronym>SAPI</acronym> in contrast
431
-
to the situation in Apache 1, where it's set to the same value as
432
-
the <envar>SCRIPT_FILENAME</envar> server variable when it's not
433
-
populated by Apache. This change was made to comply with the
434
-
<acronym>CGI</acronym> specification that
435
-
<envar>PATH_TRANSLATED</envar> should only exist if
436
-
<envar>PATH_INFO</envar> is defined.
437
-
</simpara>
438
-
<simpara>
439
336
Apache 2 users may use <literal>AcceptPathInfo = On</literal> inside
440
337
<filename>httpd.conf</filename> to define <envar>PATH_INFO</envar>.
441
338
</simpara>
...
...
@@ -501,7 +398,7 @@
501
398
<term>'<varname>AUTH_TYPE</varname>'</term>
502
399
<listitem>
503
400
<simpara>
504
-
When doing HTTP authenticated this variable is set to the
401
+
When doing HTTP authentication this variable is set to the
505
402
authentication type.
506
403
</simpara>
507
404
</listitem>
...
...
@@ -512,10 +409,9 @@
512
409
<listitem>
513
410
<simpara>
514
411
Contains any client-provided pathname information trailing the
515
-
actual script filename but preceding the query string, if
516
-
available. For instance, if the current script was accessed via
517
-
the
518
-
URL <filename>http://www.example.com/php/path_info.php/some/stuff?foo=bar</filename>,
412
+
actual script filename but preceding the query string, if available.
413
+
For instance, if the current script was accessed via the URI
414
+
<filename>http://www.example.com/php/path_info.php/some/stuff?foo=bar</filename>,
519
415
then <varname>$_SERVER['PATH_INFO']</varname> would
520
416
contain <literal>/some/stuff</literal>.
521
417
</simpara>
...
...
@@ -536,46 +432,6 @@
536
432
</para>
537
433
</refsect1>
538
434
539
-
<refsect1 role="changelog">
540
-
&reftitle.changelog;
541
-
<para>
542
-
<informaltable>
543
-
<tgroup cols="2">
544
-
<thead>
545
-
<row>
546
-
<entry>&Version;</entry>
547
-
<entry>&Description;</entry>
548
-
</row>
549
-
</thead>
550
-
<tbody>
551
-
<row>
552
-
<entry>5.4.0</entry>
553
-
<entry>
554
-
<varname>$HTTP_SERVER_VARS</varname> isn't available anymore due to
555
-
the removal of long arrays registering.
556
-
</entry>
557
-
</row>
558
-
<row>
559
-
<entry>5.3.0</entry>
560
-
<entry>
561
-
Directive <link linkend="ini.register-long-arrays">register_long_arrays</link>
562
-
which caused <varname>$HTTP_SERVER_VARS</varname> to be available has been
563
-
deprecated.
564
-
</entry>
565
-
</row>
566
-
<row>
567
-
<entry>4.1.0</entry>
568
-
<entry>
569
-
Introduced <varname>$_SERVER</varname> that deprecated
570
-
<varname>$HTTP_SERVER_VARS</varname>.
571
-
</entry>
572
-
</row>
573
-
</tbody>
574
-
</tgroup>
575
-
</informaltable>
576
-
</para>
577
-
</refsect1>
578
-
579
435
<refsect1 role="examples">
580
436
&reftitle.examples;
581
437
<para>
...
...
@@ -612,8 +468,7 @@ www.example.com
612
468
</para>
613
469
</refsect1>
614
470

615
-
</phpdoc:varentry>
616
-
471
+
</refentry>
617
472
<!-- Keep this comment at the end of the file
618
473
Local variables:
619
474
mode: sgml
620
475