(PHP 4, PHP 5)

putenvSets the value of an environment variable


bool putenv ( string $setting )

Adds setting to the server environment. The environment variable will only exist for the duration of the current request. At the end of the request the environment is restored to its original state.

Setting certain environment variables may be a potential security breach. The safe_mode_allowed_env_vars directive contains a comma-delimited list of prefixes. In Safe Mode, the user may only alter environment variables whose names begin with the prefixes supplied by this directive. By default, users will only be able to set environment variables that begin with PHP_ (e.g. PHP_FOO=BAR). Note: if this directive is empty, PHP will let the user modify ANY environment variable!

The safe_mode_protected_env_vars directive contains a comma-delimited list of environment variables, that the end user won't be able to change using putenv(). These variables will be protected even if safe_mode_allowed_env_vars is set to allow to change them.



The setting, like "FOO=BAR"


成功时返回 TRUE, 或者在失败时返回 FALSE.


Example #1 Setting an environment variable




The safe_mode_allowed_env_vars and safe_mode_protected_env_vars directives only take effect when safe_mode is enabled.


  • getenv() - Gets the value of an environment variable

  • assert
  • assert_options
  • dl
  • extension_loaded
  • gc_collect_cycles
  • gc_disable
  • gc_enable
  • gc_enabled
  • getenv
  • getlastmod
  • getmyinode
  • getopt
  • getrusage
  • get_cfg_var
  • get_current_user
  • get_defined_constants
  • get_extension_funcs
  • get_included_files
  • get_include_path
  • get_loaded_extensions
  • get_magic_quotes_gpc
  • get_magic_quotes_runtime
  • get_required_files
  • ini_alter
  • ini_get
  • ini_get_all
  • ini_restore
  • ini_set
  • magic_quotes_runtime
  • main
  • memory_get_peak_usage
  • memory_get_usage
  • phpcredits
  • phpversion
  • php_ini_loaded_file
  • php_ini_scanned_files
  • php_logo_guid
  • php_sapi_name
  • php_uname
  • putenv
  • restore_include_path
  • set_include_path
  • set_magic_quotes_runtime
  • set_time_limit
  • sys_get_temp_dir
  • version_compare
  • zend_logo_guid
  • zend_thread_id
  • zend_version
  • PHP MySQL HTML CSS JavaScript MSSQL AJAX .NET JSP Linux Mac ASP 服务器 SQL jQuery C# C++ java Android IOS oracle MongoDB SQLite wamp 交通频道


    打开 微信