PHP

⚙️ What Is PHP phpinfo()?

The phpinfo() function is a built-in PHP diagnostic tool that outputs a comprehensive HTML report containing detailed information about the PHP environment on your server.

It displays critical technical data including:

  • Installed PHP version and build details
  • Web server architecture and operating system information
  • Active extension modules (cURL, mysqli, GD, PDO, etc.)
  • Configuration directives from the core php.ini file
  • Environment and predefined system variables
  • In Short: phpinfo() = Displays server configuration, active modules, and environment status.

1️⃣ Basic Usage

Executing the function without parameters generates the default full diagnostic page in the browser:

CSS

<?php
phpinfo();
?>

2️⃣ phpinfo() Parameters & Flags

You can filter the output to show only specific configuration blocks by passing predefined bitwise constants as arguments:

🔹 1. INFO_ALL (Default)
Displays all available configuration information. Used automatically when no argument is supplied.

CSS

<?php phpinfo(INFO_ALL); ?>
				

🔹 2. INFO_LICENSE
Displays PHP license information and terms.

CSS

<?php phpinfo(INFO_LICENSE); ?>
				

🔹 3. INFO_CREDITS
Outputs the developer credits list for the core PHP development team.

CSS

<?php phpinfo(INFO_CREDITS); ?>
				

🔹 4. INFO_GENERAL
Displays general system architecture, PHP version, compilation dates, and web server interface specs.

CSS

<?php phpinfo(INFO_GENERAL); ?>
				

🔹 5. INFO_CONFIGURATION
Renders active master and local values for directives defined in php.ini.

CSS

<?php phpinfo(INFO_CONFIGURATION); ?>
				

🔹 6. INFO_MODULES
Lists all currently enabled extension modules and their respective configurations (e.g., MySQLi, cURL, GD, OpenSSL).

CSS

<?php phpinfo(INFO_MODULES); ?>
				

🔹 7. INFO_ENVIRONMENT
Displays server environment variable details.

CSS

<?php phpinfo(INFO_ENVIRONMENT); ?>
				

🔹 8. INFO_VARIABLES
Outputs predefined superglobal arrays such as $_SERVER.

CSS

<?php phpinfo(INFO_VARIABLES); ?>
				

🔒 Security Warning & Best Practices

  • ✅ Development Phase: Highly useful for verifying installed extensions or debugging environment variables on local servers (e.g., Laragon / XAMPP).
  • ❌ Production Warning: **Never** expose files containing phpinfo() on live production servers!
  • Why it is dangerous: Exposing phpinfo() reveals absolute file path details, OS kernel versions, active extension modules, and sensitive configuration limits, giving potential attackers valuable target information.
  • 📝 Brief Summary

  • phpinfo() outputs detailed server, extension, and runtime environment data.
  • Passing specific INFO_* constants filters the displayed diagnostic sections.
  • Always delete or protect diagnostic script files before deploying to live production environments.