apache_getenv

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

apache_getenv아파치 서브프로세스의 환경 변수를 가져옵니다

설명

string apache_getenv ( string $variable [, bool $walk_to_top ] )

variable로 지정한 아파치 환경 변수를 가져옵ㄴ디ㅏ.

이 함수는 아파치 2가 필요하며, 그렇지 않다면 정의되지 않습니다.

인수

variable

아파치 환경 변수

walk_top_top

모든 아파치 레이어에서 최고 레벨 변수를 가져올지 결정합니다.

반환값

성공하면 아파치 환경 변수 값, 실패하면 FALSE입니다.

예제

Example #1 apache_getenv() 예제

이 예제는 아파치 환경 변수 SERVER_ADDR을 가져오는 방볍을 보여줍니다.

<?php
$ret 
apache_getenv("SERVER_ADDR");
echo 
$ret;
?>

위 예제의 출력 예시:

42.24.42.240

참고

add a note add a note

User Contributed Notes 2 notes

up
9
elhachmi at gmail dot com
11 years ago
apache_getenv(key) does not work on an php cgi installation, in this case rather use $_SERVER["REDIRECT_key"]
up
2
Anonymous
5 years ago
This manual page is unclear as to whether it will fetch Apache configuration environment variables set by "SetEnv" (including "SetEnvIf[NoCase]" or "BrowserMatch" e.g.) as the only example given is with a pre-defined CGI interface variable (which is also available via the $_SERVER[] array).  If custom Apache runtime configuration variables are indeed fetchable via this interface, let's say so or give an example of such.
To Top