如何在PHP中设置和使用PHP_INI_SCAN_DIR环境变量?
How to set and use PHP_INI_SCAN_DIR environment variable in PHP?
我已经在 Windows 10[=32 上 运行 我的机器上安装了 PHP 7.2.3 =].我已经使用 XAMPP 软件包 .
的最新副本安装了 PHP 和 Apache httpd 4.29
我从 PHP Manual
中看到以下文字
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 the
PHP_INI_SCAN_DIR
environment variable.
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
<?php
$_ENV['PHP_INI_SCAN_DIR'] = "Jumbo";
print_r(getenv());
?>
谁能告诉我 PHP_INI_SCAN_DIR
到底是什么以及如何使用 it/set?
您可以在 .htaccess
文件或 <vhost>
部分中使用 Apaches SetEnv。
https://serverfault.com/questions/224685/php-ini-disable-scan-this-dir-for-additional-ini-files
SetEnv PHP_INI_SCAN_DIR C:/web/app/conf.d/
在 Windows 上,您还可以转到控制面板并设置 global environment variable,或按服务 AFAIK 配置它。
或安装 MSVC 和 recompile PHP 以设置自定义 ./configure
选项(例如 --with-config-file-scan-dir
)。
You probably do not want to do that.
我已经在 Windows 10[=32 上 运行 我的机器上安装了 PHP 7.2.3 =].我已经使用 XAMPP 软件包 .
的最新副本安装了 PHP 和 Apache httpd 4.29我从 PHP Manual
中看到以下文字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.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
<?php
$_ENV['PHP_INI_SCAN_DIR'] = "Jumbo";
print_r(getenv());
?>
谁能告诉我 PHP_INI_SCAN_DIR
到底是什么以及如何使用 it/set?
您可以在
.htaccess
文件或<vhost>
部分中使用 Apaches SetEnv。
https://serverfault.com/questions/224685/php-ini-disable-scan-this-dir-for-additional-ini-filesSetEnv PHP_INI_SCAN_DIR C:/web/app/conf.d/
在 Windows 上,您还可以转到控制面板并设置 global environment variable,或按服务 AFAIK 配置它。
或安装 MSVC 和 recompile PHP 以设置自定义
./configure
选项(例如--with-config-file-scan-dir
)。You probably do not want to do that.