略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: apache_setenv

2024-12-22

apache_setenv

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

apache_setenv设置 Apache 子进程环境变量

说明

apache_setenv(string $variable, string $value, bool $walk_to_top = false): bool

apache_setenv() 设置由variable指定的 Apache 环境变量值。

注意:

当设置了某 Apache 环境变量, 相应的 $_SERVER 变量不会改变。

参数

variable

将被设置的环境变量。

value

variable 值。

walk_to_top

是否将所设置的顶层变量应用到所有 Apache 层。

返回值

成功时返回 true, 或者在失败时返回 false

范例

示例 #1 使用 apache_setenv() 设置一个 Apache 环境变量

<?php
apache_setenv
("EXAMPLE_VAR""Example Value");
?>

注释

注意:

apache_setenv() 可与 apache_getenv() 配合使用,以在不同页面间传递变量,或将 PHP 脚本中已设置变量传入 Server Side Includes (.shtml)页面。

参见

add a noteadd a note

User Contributed Notes 4 notes

up
2
RLG
16 years ago
If you are using mod_gzip or mod_deflate to compress HTML output, you're not able to send partial file to the browser....

To disable mod_deflate in PHP (if needed), you can tell Apache with this :

apache_setenv('no-gzip', '1');
up
0
phpnotes at kipu dot co dot uk
19 years ago
If you set a variable, either new or existing, the corresponding $_SERVER variable is not changed, and you will have to change it as well.
up
-2
sixxgate at yahoo dot com
19 years ago
When you want to set variables to pass to Server Side Includes (.shtml) included in PHP scripts, use this.
up
-2
guilleva at gmail dot com
16 years ago
When you need to set the QUERY_STRING variable into a page included with the "virtual" function do this:

virtual ("some_page.shtml?$QUERY_STRING");

apache_setenv does not work for this case.

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

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