php_ini_loaded_file / php_ini_scanned_files

php_ini_loaded_file(): string|false · php_ini_scanned_files(): string|false

Config-file path introspection: php_ini_loaded_file returns the full path of the php.ini this process actually loaded (false when none), php_ini_scanned_files returns the comma-separated list of additional ini files parsed from the scan directory (configure --with-config-file-scan-dir) or false; pairs with ini_get — path introspection answers "where values come from", ini_get answers "what the values are".

C C23

C23
/* no ini self-report: C sees argv and environ - path introspection is
   whatever the process was handed (Linux: readlink /proc/self/exe;
   macOS: _NSGetExecutablePath) */
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
    printf("%d\n", argc >= 1);
    printf("%d\n", argv[0] != NULL);
    printf("%d\n", getenv("PATH") != NULL);
    return 0;
}
Output
1
1
1

C++ C++26

C++26
#include <cstdlib>
#include <iostream>

// same as C: argv + environ; Linux readlink("/proc/self/exe") and
// macOS _NSGetExecutablePath are the real path introspection APIs
int main(int argc, char *argv[]) {
    std::cout << (argc >= 1) << "\n";
    std::cout << (argv[0] != nullptr) << "\n";
    std::cout << (std::getenv("PATH") != nullptr) << "\n";
    return 0;
}
Output
1
1
1

C# v11.0.100

v11.0.100
using System;

// AppContext data + BaseDirectory: runtime self-path introspection, .NET style
Console.WriteLine(AppContext.BaseDirectory.Length > 0); // where the app runs from
Console.WriteLine(AppContext.GetData("no.such.key.42") == null); // unknown keys read as null
Output
True
True

Go v1.27.4

v1.27.4
package main

import (
	"fmt"
	"os"
)

// no loaded-ini introspection either: Go configs are explicit paths -
// the std fact that exists is where user configs conventionally live
func main() {
	dir, err := os.UserConfigDir()
	fmt.Println(err == nil)
	fmt.Println(dir != "")
}
Output
true
true

Java v27.0.1

v27.0.1
public class Main {
    public static void main(String[] args) {
        // JVM self-path introspection: System.properties are the "ini values",
        // java.home is the "config location" the runtime was launched with
        String home = System.getProperty("java.home");
        System.out.println(home != null && !home.isEmpty());
        System.out.println(System.getProperty("no.such.prop.42") == null);
        System.out.println(System.getProperties().size() > 10); // the inventory
    }
}
Output
true
true
true

JavaScript v26.13.1

v26.13.1
// no ini: config reaches Node via argv/env/NODE_OPTIONS - the self-path
// facts are the executable location and the environment
console.log(process.execPath.length > 0);
console.log((process.env.PATH ?? "").length > 0);
Output
true
true

PHP v8.6.0

v8.6.0
// php_ini_loaded_file(): which php.ini this process actually loaded
// php_ini_scanned_files(): extra files parsed from the scan dir
// (--with-config-file-scan-dir; ini_get reads the values these set)
$ini = php_ini_loaded_file();
var_dump(is_string($ini)); // may be false when no ini was loaded at all
echo is_string($ini) && str_ends_with(basename($ini), "php.ini") ? "path ends with php.ini\n" : "no php.ini\n"; // derived fact: the name is stable, the directory is machine-specific
$scanned = php_ini_scanned_files();
var_dump($scanned === false || is_string($scanned)); // false when the scan dir is empty - only the shape is asserted
Output
bool(true)
path ends with php.ini
bool(true)

Python v3.15.2

v3.15.2
import configparser
import os

# no process-wide ini: Python config = explicit paths parsed on demand -
# configparser.read() returns the files it actually loaded, the analog of
# "which config did I end up with"
with open("demo.ini", "w") as f:
    f.write("[app]\nport = 5432\n")
parser = configparser.ConfigParser()
loaded = parser.read("demo.ini")  # read() returns the files actually loaded
print(loaded == ["demo.ini"])
print(parser["app"]["port"])
os.remove("demo.ini")  # the probe cleans up after itself
Output
True
5432

Rust v1.99.1

v1.99.1
use std::env;

// std's real self-path introspection: current_exe - plus the environment
// (a loaded-ini analog needs a crate like config/figment in real projects)
fn main() {
    let exe = env::current_exe().expect("current_exe always answers");
    println!("{}", exe.file_name().is_some());
    println!("{}", env::var("PATH").is_ok());
    println!("{}", env::var("NO_SUCH_VAR_42").is_err());
}
Output
true
true
true

TypeScript v26.13.1

v26.13.1
// no ini: config reaches Node via argv/env/NODE_OPTIONS - the self-path
// facts are the executable location and the environment
const execPath: string = process.execPath;
console.log(execPath.length > 0);
console.log((process.env.PATH ?? "").length > 0);
Output
true
true

Language differences

Path vs values: the existing ini_get/ini_get_all entries answer "what is this directive right now", this entry answers "which file did those values come from" — step one of debugging works-locally-fails-in-production; the deterministic assertions use derived facts: php_ini_loaded_file returns a string whose basename ends with php.ini (the file name is stable, the directory is machine-specific), scanned asserts only the "false or string" shape (a scan dir may or may not exist per deployment) — no hardcoded paths.

PHP: php_ini_loaded_file() (5.2.4+) and php_ini_scanned_files() can both return false — the former when the process loaded no php.ini at all (common with --without-config-file-path or an explicit -n), the latter when the scan dir is empty; the scanned string form is a comma-separated list of file paths (each wrapped in quotes), to be exploded manually.

Python: no process-wide ini — configparser.read() returns the list of files it actually loaded (silently skipping missing ones), the closest analog of "which config did I end up with"; PYTHONSTARTUP (REPL-only) and usercustomize/sitecustomize are the other "where config comes from" hooks.

Go: likewise no loaded-config introspection — os.UserConfigDir() gives the user-config convention (macOS ~/Library/Application Support, Linux ~/.config, Windows %AppData%); viper/koanf manage multi-source config in real projects.

Java: System.getProperty("java.home") / System.getProperties() are the JVM's built-in self-inventory; -D flags and JAVA_TOOL_OPTIONS are the "where config comes from" injection points.

C#: AppContext.BaseDirectory (the app base) and AppContext.GetData(key) (host-injected data dictionary) are .NET's self-path fact sources; config files (appsettings.json) are loaded explicitly by frameworks — no implicit ini.

JavaScript/TypeScript: Node has no ini — config arrives via argv, environment variables, and NODE_OPTIONS; process.execPath is the executable self-path.

C/C++: a process cannot see a "its own config file" concept — the raw material is argv and environ; Linux readlink("/proc/self/exe") and macOS _NSGetExecutablePath are the real self-path APIs (the example keeps the minimal facts both provide).

Rust: std::env::current_exe() is cross-platform self-path introspection (wrapping Linux /proc/self/exe and macOS _NSGetExecutablePath); "load an ini and report its path" is the job of the config/figment crates in real projects.