php_ini_loaded_file() returns the path of the active php.ini file, or false when no configuration file is loaded.
<?php
$file = php_ini_loaded_file();
echo $file !== false ? $file : 'No php.ini loaded';
echo php_ini_loaded_file()
Output is True or False and the path is returned if php.ini file is loaded.
$path = php_ini_loaded_file();
if ($path) {
echo 'Path of php.ini: ' . $path;
} else {
echo 'No php.ini file is loaded';
}
Output is
Path of php.ini: C:\php\php.ini
You can get the path of php.ini by using php_info()
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.