How to know which php.ini is used?

0 votes
I search the path where the php.ini file is located in our Linux Ubuntu server, and I found many php.ini when executing the command find / -name php.ini . So how to know exactly from a php script web page where the php.ini is located ?
Oct 30 in PHP by kartik
• 35,500 points
22 views

1 answer to this question.

0 votes

Hello @kartik,

ou can use php_ini_loaded_file()

Taken from php.net:

$inipath = php_ini_loaded_file();
if ($inipath) {
    echo 'Loaded php.ini: ' . $inipath;
} else {
    echo 'A php.ini file is not loaded';
}

You may also want to check php_ini_scanned_files()

Also, you should note that if you run a PHP script from CLI, it's possible that a different php.ini file will be used than if a server (ie nginx or apache) runs it.

Other options:

  • php -i|grep 'php.ini'
  • create info.php that contains <?php phpinfo(); in the webroot, and run it in your browser
Hope it helps!!
answered Oct 30 by Niroj
• 76,940 points

Related Questions In PHP

0 votes
1 answer

What is Php Mysql Database? How php connect to database?

Hello kartik, MySQL is the most popular database ...READ MORE

answered Feb 25 in PHP by Dey
195 views
0 votes
0 answers
0 votes
1 answer

How to find the php.ini file from the command line?

Hello @kartik, You can get a full phpinfo() using : php ...READ MORE

answered May 19 in PHP by Niroj
• 76,940 points
1,378 views
0 votes
1 answer

In PHP, how to detect the execution is from CLI mode or through browser ?

Hello @kartik, Use the php_sapi_name() function. if (php_sapi_name() == "cli") { ...READ MORE

answered Oct 22 in PHP by Niroj
• 76,940 points
44 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 76,940 points
3,470 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18 in Laravel by Niroj
• 76,940 points
412 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23 in Laravel by Niroj
• 76,940 points
286 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23 in Laravel by Niroj
• 76,940 points
4,167 views
0 votes
1 answer

What is a Cookie? How to create Cookies With PHP?

A cookie is often used to identify ...READ MORE

answered Feb 13 in PHP by Niroj
• 76,940 points
481 views
0 votes
1 answer

How to check if php session is already started or not?

Hello kartik, Use session_id(), it returns an empty string ...READ MORE

answered Apr 1 in PHP by Niroj
• 76,940 points
771 views