我已在运行 Windows 10 的计算机上安装了 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
到底是什么?以及如何使用/设置它?
最佳答案
您可以在
.htaccess
中使用 Apache SetEnv文件或<vhost>
部分。
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 ,或者按服务配置它。
或者安装 MSVC 和 recompile PHP设置自定义
./configure
选项(例如--with-config-file-scan-dir
)。You probably do not want to do that.
关于php - 如何在PHP中设置和使用PHP_INI_SCAN_DIR环境变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49485364/