PHP 8.3.4 Released!

apache_getenv

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

apache_getenvRetorna uma variável subprocess_env do Apache

Descrição

apache_getenv(string $variable, bool $walk_to_top = false): string|false

Retorna a variável de ambiente do Apache especificada por variable.

Parâmetros

variable

A variável de ambiente do Apache

walk_to_top

Se deve ou não retorna a variável de alto-ní­vel disponí­veis em todas as camadas do Apache.

Valor Retornado

O valor da variável de ambiente do Apache se tiver sucesso, ou false se falhar

Exemplos

Exemplo #1 Exemplo de uso da função apache_getenv()

O exemplo abaixo mostra como obter o valor da variável de ambiente SERVER_ADDR do Apache.

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

O exemplo acima produzirá algo semelhante a:

42.24.42.240

Veja Também

add a note

User Contributed Notes 2 notes

up
5
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
1
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