如何在PHP中设置和使用PHP_INI_SCAN_DIR环境变量? [英] How to set and use PHP_INI_SCAN_DIR environment variable in PHP?
问题描述
我已在运行 Windows 10 的计算机上安装了 PHP 7.2.3 .我已经使用 XAMPP软件包的最新副本安装了PHP和 Apache httpd 4.29 .
I've installed PHP 7.2.3 on my machine running on Windows 10. I've installed PHP and Apache httpd 4.29 using latest copy of XAMPP package.
我从 PHP手册中发现以下内容
可以将PHP配置为扫描目录中的.ini文件 读取
php.ini
之后.可以在编译时通过设置 -with-config-file-scan-dir 选项.在PHP 5.2.0和更高版本中,可以通过在运行时覆盖扫描目录来设置扫描目录.PHP_INI_SCAN_DIR
环境变量.
It is possible to configure PHP to scan for .ini files in a directory after reading
php.ini
. This can be done at compile time by setting the --with-config-file-scan-dir option. In PHP 5.2.0 and later, the scan directory can then be overridden at run time by setting thePHP_INI_SCAN_DIR
environment variable.
可以通过将多个目录分开来扫描多个目录
特定于平台的路径分隔符(;在Windows,NetWare和RISC上
操作系统; :在所有其他平台上; PHP使用的值可作为
PATH_SEPARATOR 常量).如果在中给出空白目录
PHP_INI_SCAN_DIR
,PHP还将扫描编译时给定的目录
通过-with-config-file-scan-dir 设置时间.
It is possible to scan multiple directories by separating them with
the platform-specific path separator (; on Windows, NetWare and RISC
OS; : on all other platforms; the value PHP is using is available as
the PATH_SEPARATOR constant). If a blank directory is given in
PHP_INI_SCAN_DIR
, PHP will also scan the directory given at compile
time via --with-config-file-scan-dir .
我尝试了下面的代码,但无法设置环境变量PHP_INI_SCAN_DIR
I tried below code but couldn't set the environment variable PHP_INI_SCAN_DIR
<?php
$_ENV['PHP_INI_SCAN_DIR'] = "Jumbo";
print_r(getenv());
?>
请让我了解PHP_INI_SCAN_DIR
的确切含义以及如何使用/设置它.
Someone please make me understand what exactly is PHP_INI_SCAN_DIR
and how to use it/set it?
推荐答案
-
您可以在
.htaccess
文件或<vhost>
部分中使用Apaches SetEnv.
https://serverfault.com/questions/224685/php-ini-disable-scan-dir-for-additional-ini-filesYou can use Apaches SetEnv in a
.htaccess
file or<vhost>
section.
https://serverfault.com/questions/224685/php-ini-disable-scan-this-dir-for-additional-ini-filesSetEnv PHP_INI_SCAN_DIR C:/web/app/conf.d/
On Windows you can also go to the control panel and set a global environment variable, or configure it per-service AFAIK.
或安装MSVC并重新编译PHP 以设置自定义
./configure
选项(例如--with-config-file-scan-dir
).Or install MSVC and recompile PHP to set custom
./configure
options (such as--with-config-file-scan-dir
).您可能不想这样做.
You probably do not want to do that.
这篇关于如何在PHP中设置和使用PHP_INI_SCAN_DIR环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!