略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: apache_getenv

2024-11-14

apache_getenv

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

apache_getenv获取 Apache subprocess_env 变量

说明

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

获取 variable 指定的环境变量。

参数

variable

Apache 环境变量

walk_to_top

是否获取对Apache各层可用的顶层变量

返回值

成功时返回 Apache 环境变量值,失败时返回 false

范例

示例 #1 apache_getenv() 示例

该示例显示如何取得 Apache 环境变量 SERVER_ADDR的值。

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

以上例程的输出类似于:

42.24.42.240

参见

add a noteadd a note

User Contributed Notes 2 notes

up
7
elhachmi at gmail dot com
9 years ago
apache_getenv(key) does not work on an php cgi installation, in this case rather use $_SERVER["REDIRECT_key"]
up
3
Anonymous
4 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.

官方地址:https://www.php.net/manual/en/function.apache-getenv.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3