略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: php_ini_scanned_files

2024-04-29

php_ini_scanned_files

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

php_ini_scanned_files返回从额外 ini 目录里解析的 .ini 文件列表

说明

php_ini_scanned_files(): string

php_ini_scanned_files() 返回解析的 php.ini 后逗号分隔的配置文件列表。 这些文件从编译时 --with-config-file-scan-dir 选项里指定的目录里找到。

这些返回的配置文件也包括了 --with-config-file-scan-dir 选项里声明的路径。

返回值

成功时返回逗号分隔的 .ini 文件字符串。 每个逗号后紧跟新的一行。 如果未设置指令 --with-config-file-scan-dir 将会返回 false。 如果它设置了,并且目录是空的,将会返回一个空字符串。 如果有未识别的文件,此文件也会进入返回的字符串,但是会导致一个 PHP 错误。 此 PHP 错误即会在编译时出现也会在使用 php_ini_scanned_files() 函数时出现。

范例

示例 #1 列出返回的 ini 文件的简单例子

<?php
if ($filelist php_ini_scanned_files()) {
    if (
strlen($filelist) > 0) {
        
$files explode(','$filelist);

        foreach (
$files as $file) {
            echo 
"<li>" trim($file) . "</li>\n";
        }
    }
}
?>

参见

add a noteadd a note

User Contributed Notes 1 note

up
0
atesin () gmail ! com
3 years ago
<warning>

until i load more .ini files from <php-dir>/php.d/ as listed in phpinfo() (sections "Scan this dir for additional .ini files" and "Additional .ini files parsed"), php_ini_scanned_files() returns me NOTHING!

then i realized my php binary was not compiled with the "--with-config-file-scan-dir" option as listed in phpinfo() (section "Configure Command")

then i remembered the additional .ini files dir was set through the "PHP_INI_SCAN_DIR" system variable (new since php 5.2.0, see https://php.net/manual/en/configuration.file.php#configuration.file.scan)

until confusing and annoying, is the documented behavior... too bad now i don't know how to get the additional ini files purely with php functions (except "shell_exec()" maybe?)

</warning>

官方地址:https://www.php.net/manual/en/function.php-ini-scanned-files.php

冷却塔厂家 广告
中文GPT4.0无需注册 广告
北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3