php
REQUEST_TIME => 1174440456
As you can see, quite a bit of information is available??”some useful, some not so
useful. You can display just one of these variables simply by treating it as a regular
variable. For example, use this to display the user??™s IP address:
printf("Your IP address is: %s", $_SERVER['REMOTE_ADDR']);
This returns a numerical IP address, such as 192.0.34.166.
You can also gain information regarding the user??™s browser and operating system.
Consider the following one-liner:
printf("Your browser is: %s", $_SERVER['HTTP_USER_AGENT']);
This returns information similar to the following:
Your browser is: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US;
rv:1.8.0.10)Gecko/20070216 Firefox/1.5.0.10
This example illustrates only one of PHP??™s nine predefined variable arrays. The rest
of this section is devoted to introducing the purpose and contents of each.
?– Note To use the predefined variable arrays, the configuration parameter track_vars must be
enabled in the php.ini file. As of PHP 4.03, track_vars is always enabled.
Learning More About the Server and Client
The $_SERVER superglobal contains information created by the Web server and offers
a bevy of information regarding the server and client configuration and the current
request environment. Although the value and number of variables found in $_SERVER
varies by server, you can typically expect to find those defined in the CGI 1.
Pages:
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167