본문으로 바로가기

PHP 자주 사용하는 SERVER 변수

category PHP 2020. 2. 17. 20:25
반응형

 


PHP 개발을 하면서 SERVER 변수를 가끔 사용하긴 하지만 사용할때마다 찾아보게 되어서 자주 사용하는 SERVER 변수만 정리해보려고 합니다.

 

사용법

$_SERVER['DOCUMENT_ROOT']
$_SERVER['REMOTE_ADDR']
$_SERVER['SERVER_ADDR']
$_SERVER['HTTP_REFERER']
$_SERVER['SERVER_NAME']
$_SERVER['HTTP_HOST']
$_SERVER['SERVER_PORT']
$_SERVER['REQUEST_URI']
$_SERVER['PHP_SELF']
$_SERVER['QUERY_STRING']

 

'DOCUMENT_ROOT'

The document root directory under which the current script is executing, as defined in the server's configuration file.

서버의 구성 파일에 정의 된대로 현재 스크립트가 실행중인 문서 루트 디렉토리입니다.
          >>> 물리적인 주소 : /home/www/local~~~

'REMOTE_ADDR'

The IP address from which the user is viewing the current page.

사용자가 현재 페이지를보고있는 IP 주소입니다.
          >>> 접속한 IP : 192.168.0.100

'SERVER_ADDR'

The IP address of the server under which the current script is executing.

현재 스크립트가 실행중인 서버의 IP 주소입니다.
>>> 서버 IP : 192.168.0.100

'HTTP_REFERER'

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. 

Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

사용자 에이전트를 현재 페이지로 참조한 페이지의 주소입니다 (있는 경우). 이것은 사용자 에이전트에 의해 설정됩니다. 모든 사용자 에이전트가이를 설정하지는 않으며 일부는 HTTP_REFERER 를 기능으로 수정하는 기능을 제공합니다 . 간단히 말해 실제로 신뢰할 수는 없습니다.
          >>> 이전 주소 : https://test.com/search.php

'SERVER_NAME'

The name of the server host under which the current script is executing. 

If the script is running on a virtual host, this will be the value defined for that virtual host.

현재 스크립트가 실행중인 서버 호스트의 이름입니다. 스크립트가 가상 호스트에서 실행중인 경우 해당 가상 호스트에 대해 정의 된 값이됩니다.
          >>> 서버 호스트 이름 : test.com

'HTTP_HOST'

Contents of the Host: header from the current request, if there is one.

현재 요청 의 Host : 헤더 내용 (있는 경우)
          >>> 현재 요청에 대한 Host 헤더의 내용 : test.com

'SERVER_PORT'

The port on the server machine being used by the web server for communication.

웹 서버가 통신을 위해 사용중인 서버 시스템의 포트입니다. 
          >>> 사이트 포트 번호 : 80

'REQUEST_URI'

The URI which was given in order to access this page

이 페이지에 액세스하기 위해 제공된 URI입니다.
          >>> URI : /search.html?type=1

'PHP_SELF'

The filename of the currently executing script, relative to the document root.

문서 루트를 기준으로 현재 실행중인 스크립트의 파일 이름입니다
          >>> 현재페이지의 주소에서 도메인과 넘겨지는 값 제외 : /search.html

'QUERY_STRING'

The query string, if any, via which the page was accessed.

페이지에 액세스 한 쿼리 문자열입니다 (있는 경우)

          >>> GET 방식의 파일명 뒤에 붙어서 넘어오는 파라미터 값 : type=1

 

 

 

<참조 php.net>

 

 

반응형

'PHP' 카테고리의 다른 글

PDO insert, update, delete 한 행 수 확인하기  (0) 2020.02.18
PHP 비동기 처리  (2) 2020.02.12
PHP CURL 사용법  (0) 2020.02.06
PHP 값이 배열 안에 존재하는지 확인하는 in_array 함수  (0) 2020.01.31
PHP 문자열 함수  (0) 2019.12.04