PHP переменная $_SERVER

Материал из Энциклопедия о программировании
Перейти к: навигация, поиск

$_SERVER — доступный везде т.н. «суперглобальный массив» в PHP, который содержит служебную инфо о сервере, запросе, соединении и среде исполнения.

Примеры

Типичное содержимое переменной $_SERVER: Array ( [REDIRECT_STATUS] => 200 [HTTP_HOST] => domain.loc [HTTP_X_FORWARDED_FOR] => 255.255.255.255 [HTTP_X_REAL_IP] => 255.255.255.255 [HTTP_CONNECTION] => close [HTTP_PRAGMA] => no-cache [HTTP_CACHE_CONTROL] => max-age=0 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 [HTTP_REFERER] => http://domain.loc [HTTP_UPGRADE_INSECURE_REQUESTS] => 1 [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36 [HTTP_ACCEPT_ENCODING] => gzip, deflate, sdch [HTTP_ACCEPT_LANGUAGE] => ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4 [HTTP_COOKIE] => prefix_codeUserID=56492; codeUserName=User; codeToken=dbbe1a4aa [PATH] => /usr/local/bin:/usr/bin:/bin [SERVER_SIGNATURE] => SomeWebServer/5.0 (OS) Server at domain.loc Port 80 [SERVER_SOFTWARE] => SomeWebServer/5.0 (OS) [SERVER_NAME] => domain.loc [SERVER_ADDR] => 127.0.0.1 [SERVER_PORT] => 80 [REMOTE_ADDR] => 255.255.255.255 [DOCUMENT_ROOT] => /sites/domain.loc/www [SERVER_ADMIN] => [no address given] [SCRIPT_FILENAME] => /sites/domain.loc/www/w/index.php [REMOTE_PORT] => 58907 [REDIRECT_QUERY_STRING] => title=Заглавная [REDIRECT_URL] => /code/Заглавная [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.0 [REQUEST_METHOD] => GET [QUERY_STRING] => title=Заглавная [REQUEST_URI] => /code/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F [SCRIPT_NAME] => /w/index.php [PHP_SELF] => /w/index.php [REQUEST_TIME] => 1453937403 )

Шаблон:PHP