---
title: $_SERVER
description: "> super global variables are built-in variables that are always available in all scopes. > > > > super global хувьсагчид нь бүх хүрээнд үргэлж бэлэн байдаг хувьсагч юм. --- ## PHP $_SERVER $_SERVER is a PHP super global variable…"
url: "https://apprentice.mn/docs/_server/"
updated: "2021-07-09"
category: PHP
---

# $_SERVER

> super global variables are built-in variables that are always available in all scopes.
>
>
>
> super global хувьсагчид нь бүх хүрээнд үргэлж бэлэн байдаг хувьсагч юм.

---

## PHP $_SERVER

$_SERVER is a PHP super global variable which holds information about headers, paths, and script locations.

$ _SERVER бол толгой, зам, скрипт байршлын талаархи мэдээллийг агуулдаг PHP super global  хувьсагч юм.

The example below shows how to use some of the elements in $_SERVER:

$ _SERVER доторх зарим элементүүдийг хэрхэн ашиглахыг доорх жишээн дээр харуулав.

### Example

### Жишээ

      `<?php
echo $_SERVER['PHP_SELF'];
echo "<br>";
echo $_SERVER['SERVER_NAME'];
echo "<br>";
echo $_SERVER['HTTP_HOST'];
echo "<br>";
echo $_SERVER['HTTP_REFERER'];
echo "<br>";
echo $_SERVER['HTTP_USER_AGENT'];
echo "<br>";
echo $_SERVER['SCRIPT_NAME'];
?>`

The following table lists the most important elements that can go inside $_SERVER:

Дараах хүснэгтэд $ _SERVER дотор орж болох хамгийн чухал элементүүдийг жагсаав.

| Element/Code | Description |
| --- | --- |
| $_SERVER\[‘PHP_SELF’\] | Returns the filename of the currently executing script Яг одоо хэрэгжүүлж байгаа скриптийн файлын нэрийг буцаана |
| $_SERVER\[‘GATEWAY_INTERFACE’\] | Returns the version of the Common Gateway Interface (CGI) the server is using Сервер ашиглаж буй Common Gateway Interface (CGI) хувилбарыг буцаана |
| $_SERVER\[‘SERVER_ADDR’\] | Returns the IP address of the host server Хост серверийн IP хаягийг буцаана |
| $_SERVER\[‘SERVER_NAME’\] | Returns the name of the host server (such as www.Apprentice.mn) Хост серверийн нэрийг буцаана (www.Apprentice.mn гэх мэт) |
| $_SERVER\[‘SERVER_SOFTWARE’\] | Returns the server identification string (such as Apache/2.2.24) Сервер таних мөрийг буцаана (Apache / 2.2.24 гэх мэт) |
| $_SERVER\[‘SERVER_PROTOCOL’\] | Returns the name and revision of the information protocol (such as HTTP/1.1) Мэдээллийн протоколын нэр, засварыг буцааж өгдөг (HTTP / 1.1 гэх мэт) |
| $_SERVER\[‘REQUEST_METHOD’\] | Returns the request method used to access the page (such as POST) Хуудсанд нэвтрэхэд ашигласан хүсэлтийн аргыг буцаана (POST гэх мэт) |
| $_SERVER\[‘REQUEST_TIME’\] | Returns the timestamp of the start of the request (such as 1377687496) Хүсэлтийн эхлэх цаг хугацааны тэмдэг (1377687496 гэх мэт) -ийг буцаана. |
| $_SERVER\[‘QUERY_STRING’\] | Returns the query string if the page is accessed via a query string Хэрэв хуудсанд асуулга мөрөөр хандаж байвал асуулга мөрийг буцаана |
| $_SERVER\[‘HTTP_ACCEPT’\] | Returns the Accept header from the current request Одоогийн хүсэлтээс хүлээн авах толгой нүүр хэсгийг буцаана |
| $_SERVER\[‘HTTP_ACCEPT_CHARSET’\] | Returns the Accept_Charset header from the current request (such as utf-8,ISO-8859-1) Accept_Charset толгой нүүр хэсгийг одоогийн хүсэлтээс буцааж өгдөг (utf-8, ISO-8859-1 гэх мэт) |
| $_SERVER\[‘HTTP_HOST’\] | Returns the Host header from the current request Одоогийн хүсэлтээс Хостын толгойг буцаана |
| $_SERVER\[‘HTTP_REFERER’\] | Returns the complete URL of the current page (not reliable because not all user-agents support it) Одоогийн хуудасны бүрэн URL-г буцаана (бүх хэрэглэгчийн агентууд дэмждэггүй тул найдвартай биш) |
| $_SERVER\[‘HTTPS’\] | Is the script queried through a secure HTTP protocol Скриптийг аюулгүй HTTP протоколоор дамжуулан асуусан уу |
| $_SERVER\[‘REMOTE_ADDR’\] | Returns the IP address from where the user is viewing the current page Хэрэглэгч тухайн хуудсыг үзэж байгаа газраас IP хаягийг буцаана |
| $_SERVER\[‘REMOTE_HOST’\] | Returns the Host name from where the user is viewing the current page Хэрэглэгчийн одоогийн хуудсыг үзэж байгаа байршлын нэрийг буцаана |
| $_SERVER\[‘REMOTE_PORT’\] | Returns the port being used on the user’s machine to communicate with the web server Вэб сервертэй холбогдоход хэрэглэгчийн машин дээр ашиглаж буй портыг буцаана |
| $_SERVER\[‘SCRIPT_FILENAME’\] | Returns the absolute pathname of the currently executing script Яг одоо хэрэгжүүлж буй скриптийн бүрэн нийлмэл нэрийг буцаана |
| $_SERVER\[‘SERVER_ADMIN’\] | Returns the value given to the SERVER_ADMIN directive in the web server configuration file (if your script runs on a virtual host, it will be the value defined for that virtual host) (such as i@apprentice.mn) Вэб серверийн тохиргооны файл дахь SERVER_ADMIN удирдамжид өгсөн утгыг буцаана (хэрэв таны скрипт виртуал хост дээр ажилладаг бол тухайн виртуал хостын хувьд тодорхойлогдсон утга байх болно) (i@apprentice.mn гэх мэт) |
| $_SERVER\[‘SERVER_PORT’\] | Returns the port on the server machine being used by the web server for communication (such as 80) Вэб серверийн харилцаа холбооны зорилгоор ашиглаж буй сервер машин дээрх портыг буцаана (80 гэх мэт) |
| $_SERVER\[‘SERVER_SIGNATURE’\] | Returns the server version and virtual host name which are added to server-generated pages Серверээс үүсгэсэн хуудсанд нэмсэн серверийн хувилбар болон виртуал хостын нэрийг буцаана |
| $_SERVER\[‘PATH_TRANSLATED’\] | Returns the file system based path to the current script Файлын системд суурилсан замыг одоогийн скрипт рүү буцаана |
| $_SERVER\[‘SCRIPT_NAME’\] | Returns the path of the current script Одоогийн скриптийн замыг буцаана |
| $_SERVER\[‘SCRIPT_URI’\] | Returns the URI of the current page Одоогийн хуудасны URI-г буцаана |

        [https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2F_server%2F&linkname=%24_SERVER](https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2F_server%2F&linkname=%24_SERVER)[https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2F_server%2F&linkname=%24_SERVER](https://www.addtoany.com/add_to/mastodon?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2F_server%2F&linkname=%24_SERVER)[https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2F_server%2F&linkname=%24_SERVER](https://www.addtoany.com/add_to/email?linkurl=https%3A%2F%2Fapprentice.mn%2Fdocs%2F_server%2F&linkname=%24_SERVER)[https://www.addtoany.com/share](https://www.addtoany.com/share)
