Is it possible to get the path to the php.ini file with a php script and save this path to a variable? I know I can call phpinfo() to find out the path, but it prints a lot of info and I only need the path to php.ini file and no output at all. Thank you in advance.
Sure, there are two functions related to what you would like to do. The first one is exactly what you're looking for, the second one shows the bigger picture that there can be more than one ini file:
php_ini_loaded_fileDocs - Retrieve a path to the loaded php.ini file.php_ini_scanned_filesDocs - Return a list of .ini files parsed from the additional ini dir.Next to that, mind the gap with .user.ini files, they don't show up in php_ini_scanned_files nor phpinfo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With