How can I know which 'php.ini' file is used?
You 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 (e.g., 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
Who reads the 'php.ini' file and how many php.ini files can possibly be exist there? What's the role of every such 'php.ini' file?
- The PHP compiler/parser.
- Because PHP does not persist for command line invocations, so it is read at run-time.
- Every time you call a PHP script, either CGI or CLI.
- More than one, typically 2. One for the web server and one for CLI/CGI.
How can I find the php.ini file used by the command line?
Just run php --ini
and look for Loaded Configuration File in the output for the location of php.ini
used by your CLI.
How is php.ini related to php.ini-development and php.ini-production?
They are template files for you to copy over to your actual php.ini
if you feel it matches your environment's needs.
- Development environment offers verbose messages and comfortable optional features, what you want when you're coding your scripts.
- Production environment is typically more minimalist (i.e. errors are logged rather than displayed, etc), for interacting with real users efficiently.
Related Topics
Avoid Public Folder of Laravel and Open Directly the Root in Web Server
Multiple Excerpt Lengths in Wordpress
Variable Type Hinting in Netbeans (Php)
Authorization Header Missing in PHP Post Request
How to Get a One-Dimensional Scalar Array as a Doctrine Dql Query Result
PHP Sessions in a Load Balancing Cluster - How
Rest API Authorization & Authentication (Web + Mobile)
PHP Composer Update "Cannot Allocate Memory" Error (Using Laravel 4)
What Is Normalized Utf-8 All About
How to Query All the Graphql Type Fields Without Writing a Long Query
Reconnection of Client When Server Reboots in Websocket
How to Password-Protect PHP Page
How to Set Up Use Httponly Cookies in PHP
Running a Zend Framework Action from Command Line
What Is the Advantage of Using Try {} Catch {} Versus If {} Else {}