PHP phpinfo(): Check the active configuration and extensions
phpinfo() displays the PHP version, effective configuration, and extensions of the runtime that calls it. A web request normally produces HTML, while the command line produces text. For a website problem, check the PHP runtime serving that site. The command line can use a different version or php.ini on the same machine.
Run phpinfo() locally
On a development computer with PHP on the command line, create an empty working directory and save the following code as phpinfo.php. It displays general information, configuration, and modules. The standalone PHP file does not need a closing PHP tag.
<?php
phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES);
Run the command below from the file’s directory. Open http://127.0.0.1:8000/phpinfo.php to see the information table. If port 8000 is in use, change it in both the command and the URL. Press Ctrl+C in the terminal when finished. This binds the development server to the local loopback address. PHP Manual — Built-in web server
php -S 127.0.0.1:8000 -t .
The output describes the server you just started. To diagnose FPM or a web server module used by an existing site, run the file in a private development environment with matching PHP settings. Double-clicking the PHP file and opening a file: URL does not execute it.
Read the configuration table
| Label in the output | What to check |
|---|---|
| PHP Version | The PHP version that handled this request. |
| Server API | Whether PHP runs through FPM, a web server module, or a command-line interface. |
| Loaded Configuration File | The main configuration file read by PHP. An empty or missing value can mean that it did not load one. |
| Additional .ini files parsed | The additional ini files read by PHP. Check for a directive defined again in another file. |
| Local Value / Master Value | The effective value in the current context and its baseline. For a difference, look for runtime-specific overrides or application changes. |
| Extension sections | Section headings for loaded extensions. Search for the extension by name. |
If a web request cannot find a mysqli function, look for the mysqli section in the web result. Finding the extension in the terminal does not establish that the web runtime loaded it. If a php.ini change has no effect, start by comparing the main and additional configuration files in the table. A persistent process such as PHP-FPM may need a reload or restart to reread its configuration. PHP Manual — The configuration file
Choose what to output and understand the return value
With no argument, the function uses INFO_ALL. The first example combines flags with the bitwise OR operator |. To see only extensions, use INFO_MODULES as shown below. Output that includes INFO_ENVIRONMENT or INFO_VARIABLES can reveal environment and request data. Even a limited selection belongs in a private environment. PHP Manual — phpinfo()
<?php
phpinfo(INFO_MODULES);
INFO_MODULES omits the general configuration table but can still show settings inside individual module sections.
The function prints its output and returns true. Writing echo phpinfo() can therefore append a 1. To check one directive, use a targeted query such as ini_get('memory_limit'). To check whether an extension is loaded, use extension_loaded('mysqli').
Compare web and command-line results
Run the saved file with the second command to get the same selection of sections as text. The first command reports the version, the third lists the configuration files, and the last lists the loaded modules. Use php -i if you need the full information output for CLI PHP. PHP Manual — Command line options
php -v
php phpinfo.php
php --ini
php -m
Compare the version, Server API, loaded configuration files, and modules in that order. SAPI is the interface through which PHP receives and handles requests. Read it through PHP_SAPI or php_sapi_name(). A command-line invocation reports cli, while the built-in web server reports cli-server. PHP Manual — php_sapi_name()
Resolve errors and remove the diagnostic file
For a 404, check the document root and filename. If the source appears or is downloaded, take the file out of the served directory and inspect the web server’s PHP handling. For a blank page or 500 response, check the PHP process’s error log, file read permissions, and syntax.
Remove the diagnostic file when finished and verify that the URL no longer returns the PHP report. If you need to share findings, copy only the values relevant to the issue and redact internal paths, names, credentials, and request data.




