apache_setenv

(PHP 4 >= 4.2.0, PHP 5)

apache_setenv -- Set an Apache subprocess_env variable

说明

bool apache_setenv ( string variable, string value [, bool walk_to_top] )

apache_setenv() sets the value of the Apache environment variable specified by variable.

注: When setting an Apache environment variable, the corresponding $_SERVER variable is not changed.

参数

variable

The environment variable that's being set.

value

The new variable value.

walk_to_top

Whether to set the top-level variable available to all Apache layers.

返回值

如果成功则返回 TRUE,失败则返回 FALSE

范例

例子 1. Setting an Apache environment variable using apache_setenv()

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

注释

注: apache_setenv() can be paired up with apache_getenv() across separate pages or for setting variables to pass to Server Side Includes (.shtml) that have been included in PHP scripts.


add a note add a note User Contributed Notes
RLG
10-Jan-2006 08:16
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');
guilleva at gmail dot com
29-Jul-2005 01:25
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.
phpnotes at kipu dot co dot uk
04-Jun-2003 09:34
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.
sixxgate at yahoo dot com
23-Jan-2003 07:56
When you want to set variables to pass to Server Side Includes (.shtml) included in PHP scripts, use this.