language/predefined/variables/server.xml
a6d209f4ff71ccba3f1255902827f5df3e092ff9
...
...
@@ -1,45 +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.
22
21
</para>
23
22
<note>
24
23
<simpara>
25
-
Prior to PHP 5.4.0, <varname>$HTTP_SERVER_VARS</varname> contained the same initial
26
-
information, but was not a <link linkend="language.variables.superglobals">superglobal</link>.
27
-
(Note that <varname>$HTTP_SERVER_VARS</varname> and <varname>$_SERVER</varname>
28
-
were different variables and that PHP handled them as such.)
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.
29
26
</simpara>
30
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>.
35
+
</para>
31
36
</refsect1>
32
37

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

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

43
41
<para>
44
42
<variablelist>
45
43
<varlistentry>
...
...
@@ -57,7 +55,7 @@
57
55
</simpara>
58
56
<simpara>
59
57
If PHP is running as a command-line processor this variable contains
60
-
the script name since PHP 4.3.0. Previously it was not available.
58
+
the script name.
61
59
</simpara>
62
60
</listitem>
63
61
</varlistentry>
...
...
@@ -89,7 +87,7 @@
89
87
<listitem>
90
88
<simpara>
91
89
What revision of the CGI specification the server is using;
92
-
i.e. '<literal>CGI/1.1</literal>'.
90
+
e.g. <literal>'CGI/1.1'</literal>.
93
91
</simpara>
94
92
</listitem>
95
93
</varlistentry>
...
...
@@ -114,9 +112,9 @@
114
112
</simpara>
115
113
<note>
116
114
<simpara>
117
-
Under Apache 2, you must set <literal>UseCanonicalName = On</literal>
118
-
and <literal>ServerName</literal>. Otherwise, this value reflects the
119
-
hostname supplied by the client, which can be spoofed.
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.
120
118
It is not safe to rely on this value in security-dependent contexts.
121
119
</simpara>
122
120
</note>
...
...
@@ -138,7 +136,7 @@
138
136
<listitem>
139
137
<simpara>
140
138
Name and revision of the information protocol via which the
141
-
page was requested; i.e. '<literal>HTTP/1.0</literal>';
139
+
page was requested; e.g. <literal>'HTTP/1.0'</literal>;
142
140
</simpara>
143
141
</listitem>
144
142
</varlistentry>
...
...
@@ -147,8 +145,8 @@
147
145
<term>'<varname>REQUEST_METHOD</varname>'</term>
148
146
<listitem>
149
147
<simpara>
150
-
Which request method was used to access the page; i.e. '<literal>GET</literal>',
151
-
'<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>.
152
150
</simpara>
153
151
<note>
154
152
<para>
...
...
@@ -164,7 +162,7 @@
164
162
<term>'<varname>REQUEST_TIME</varname>'</term>
165
163
<listitem>
166
164
<simpara>
167
-
The timestamp of the start of the request. Available since PHP 5.1.0.
165
+
The timestamp of the start of the request.
168
166
</simpara>
169
167
</listitem>
170
168
</varlistentry>
...
...
@@ -174,7 +172,6 @@
174
172
<listitem>
175
173
<simpara>
176
174
The timestamp of the start of the request, with microsecond precision.
177
-
Available since PHP 5.4.0.
178
175
</simpara>
179
176
</listitem>
180
177
</varlistentry>
...
...
@@ -199,109 +196,12 @@
199
196
</varlistentry>
200
197

201
198
<varlistentry>
202
-
<term>'<varname>HTTP_ACCEPT</varname>'</term>
203
-
<listitem>
204
-
<simpara>
205
-
Contents of the <literal>Accept:</literal> header from the
206
-
current request, if there is one.
207
-
</simpara>
208
-
</listitem>
209
-
</varlistentry>
210
-

211
-
<varlistentry>
212
-
<term>'<varname>HTTP_ACCEPT_CHARSET</varname>'</term>
213
-
<listitem>
214
-
<simpara>
215
-
Contents of the <literal>Accept-Charset:</literal> header
216
-
from the current request, if there is one. Example:
217
-
'<literal>iso-8859-1,*,utf-8</literal>'.
218
-
</simpara>
219
-
</listitem>
220
-
</varlistentry>
221
-

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

252
-
<varlistentry>
253
-
<term>'<varname>HTTP_HOST</varname>'</term>
254
-
<listitem>
255
-
<simpara>
256
-
Contents of the <literal>Host:</literal> header from the
257
-
current request, if there is one.
258
-
</simpara>
259
-
</listitem>
260
-
</varlistentry>
261
-

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

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

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

...
...
@@ -325,9 +225,9 @@
325
225
</simpara>
326
226
<note>
327
227
<simpara>
328
-
Your web server must be configured to create this variable. For
329
-
example in Apache you'll need <literal>HostnameLookups On</literal>
330
-
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
331
231
<function>gethostbyaddr</function>.
332
232
</simpara>
333
233
</note>
...
...
@@ -397,16 +297,16 @@
397
297
<listitem>
398
298
<simpara>
399
299
The port on the server machine being used by the web server
400
-
for communication. For default setups, this will be '<literal>80</literal>';
300
+
for communication. For default setups, this will be <literal>'80'</literal>;
401
301
using SSL, for instance, will change this to whatever your
402
302
defined secure HTTP port is.
403
303
</simpara>
404
304
<note>
405
305
<simpara>
406
-
Under the Apache 2, you must set <literal>UseCanonicalName = On</literal>,
407
-
as well as <literal>UseCanonicalPhysicalPort = On</literal> in order to
408
-
get the physical (real) port, otherwise, this value can be spoofed and it
409
-
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.
410
310
It is not safe to rely on this value in security-dependent contexts.
411
311
</simpara>
412
312
</note>
...
...
@@ -433,16 +333,6 @@
433
333
</simpara>
434
334
<note>
435
335
<simpara>
436
-
As of PHP 4.3.2, <envar>PATH_TRANSLATED</envar> is no longer set
437
-
implicitly under the Apache 2 <acronym>SAPI</acronym> in contrast
438
-
to the situation in Apache 1, where it's set to the same value as
439
-
the <envar>SCRIPT_FILENAME</envar> server variable when it's not
440
-
populated by Apache. This change was made to comply with the
441
-
<acronym>CGI</acronym> specification that
442
-
<envar>PATH_TRANSLATED</envar> should only exist if
443
-
<envar>PATH_INFO</envar> is defined.
444
-
</simpara>
445
-
<simpara>
446
336
Apache 2 users may use <literal>AcceptPathInfo = On</literal> inside
447
337
<filename>httpd.conf</filename> to define <envar>PATH_INFO</envar>.
448
338
</simpara>
...
...
@@ -519,10 +409,9 @@
519
409
<listitem>
520
410
<simpara>
521
411
Contains any client-provided pathname information trailing the
522
-
actual script filename but preceding the query string, if
523
-
available. For instance, if the current script was accessed via
524
-
the
525
-
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>,
526
415
then <varname>$_SERVER['PATH_INFO']</varname> would
527
416
contain <literal>/some/stuff</literal>.
528
417
</simpara>
...
...
@@ -543,46 +432,6 @@
543
432
</para>
544
433
</refsect1>
545
434
546
-
<refsect1 role="changelog">
547
-
&reftitle.changelog;
548
-
<para>
549
-
<informaltable>
550
-
<tgroup cols="2">
551
-
<thead>
552
-
<row>
553
-
<entry>&Version;</entry>
554
-
<entry>&Description;</entry>
555
-
</row>
556
-
</thead>
557
-
<tbody>
558
-
<row>
559
-
<entry>5.4.0</entry>
560
-
<entry>
561
-
<varname>$HTTP_SERVER_VARS</varname> isn't available anymore due to
562
-
the removal of long arrays registering.
563
-
</entry>
564
-
</row>
565
-
<row>
566
-
<entry>5.3.0</entry>
567
-
<entry>
568
-
Directive <link linkend="ini.register-long-arrays">register_long_arrays</link>
569
-
which caused <varname>$HTTP_SERVER_VARS</varname> to be available has been
570
-
deprecated.
571
-
</entry>
572
-
</row>
573
-
<row>
574
-
<entry>4.1.0</entry>
575
-
<entry>
576
-
Introduced <varname>$_SERVER</varname> that deprecated
577
-
<varname>$HTTP_SERVER_VARS</varname>.
578
-
</entry>
579
-
</row>
580
-
</tbody>
581
-
</tgroup>
582
-
</informaltable>
583
-
</para>
584
-
</refsect1>
585
-
586
435
<refsect1 role="examples">
587
436
&reftitle.examples;
588
437
<para>
...
...
@@ -619,8 +468,7 @@ www.example.com
619
468
</para>
620
469
</refsect1>
621
470

622
-
</phpdoc:varentry>
623
-
471
+
</refentry>
624
472
<!-- Keep this comment at the end of the file
625
473
Local variables:
626
474
mode: sgml
627
475