Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get and save path to php.ini file

Tags:

path

php

php-ini

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.

like image 804
noname Avatar asked Apr 27 '26 11:04

noname


1 Answers

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:

  1. php_ini_loaded_fileDocs - Retrieve a path to the loaded php.ini file.
  2. 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.

like image 177
hakre Avatar answered Apr 29 '26 02:04

hakre



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!