How to find out which php.ini file PHP is using?

PHP: How to find out which php.ini file PHP is using?

To find out which php.ini file (and its full file path) just run the following command:

php --ini

Which will output something like this:

$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

If you need to check from within a PHP script, you can either put this code in (if it isn't public facing) and search for 'Loaded configuration file':

  1. <?php phpinfo(); ?>

Or run:

  1. <?php var_dump(php_ini_loaded_file()); ?>

See also: php_ini_scanned_files()

webdevetc profile pic

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This ( is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.


Comments and discussion about How to find out which php.ini file PHP is using?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the PHP language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to find out what version of Laravel you are using?

How to block multiple IP addresses in .htaccess

Why should you update APP_URL from from http://localhost?

What is the difference between var, let and const in Javascript?

Remove trailing slash (redirect to remove trailing slash) in .htaccess

How to check if a string contains a certain substring?

How to add the CSRF (Cross-site request forgery) token in Laravel?

What are generators in PHP, and how do they compare to arrays?

How could you include a custom function for every single time PHP runs?

How do you run a PHP script from the command line?