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
webdevetc

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



More...


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 set up an alias to map one directory to another destination

What is the spaceship operator (<=>) in PHP?

How to check if a string contains a certain substring?

How to set the Expires header in .htaccess

How to fix the MySQL related "Specified key was too long error" error in Laravel

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

What is the difference between reference and primitive data types types in Javascript?

How to get the type of a variable in JS?

How to check if an object or variable is an array, in JS?

How to output (echo/print) content in PHP