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, 2020 in PHP by kartik
• 37,490 points
54 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, 2020 by Niroj
• 82,580 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, 2020 in PHP by Dey
230 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, 2020 in PHP by Niroj
• 82,580 points
4,987 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, 2020 in PHP by Niroj
• 82,580 points
84 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, 2020 in Laravel by Niroj
• 82,580 points
5,656 views
0 votes
1 answer

What is redirection in Laravel?

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

answered Mar 18, 2020 in Laravel by Niroj
• 82,580 points
656 views
0 votes
1 answer

How to install Laravel via composer?

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

answered Mar 23, 2020 in Laravel by Niroj
• 82,580 points
499 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, 2020 in Laravel by Niroj
• 82,580 points
6,231 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, 2020 in PHP by Niroj
• 82,580 points
867 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, 2020 in PHP by Niroj
• 82,580 points
1,303 views