How Do I Display PHP Information Using PHPinfo

As a PHP developer, it’s important to know the details of the environment your PHP scripts are running in.

You can find these details using the phpinfo() function.

This function displays information about the current PHP installation, such as the version number, configuration settings, and extensions loaded.

In this tutorial, we will look at how to use phpinfo() and what information you can retrieve from it.


Using the PHPinfo Function

To display the PHP information, simply create a new PHP file with the following code:

<?php
phpinfo();
?>

Save the file and run it in your web browser. You should see a page similar to the one below:

phpinfo() output

As you can see, the phpinfo() function displays a lot of information about your PHP installation.

The information is divided into sections, such as “General”, “Apache Environment”, and “PHP Variables”.

Understanding the Output

Here’s a brief overview of some of the sections you might find in the output of the phpinfo() function:

  • General: This section contains information about the PHP version number, build date, server API, and more.
  • Apache Environment: If your PHP installation is running on an Apache server, this section will show information about the Apache version, server name, and more.
  • PHP Variables: This section displays all the PHP configuration settings, such as the maximum execution time, memory limit, and error reporting level.
  • Configuration File (php.ini) Path: This section displays the path to the php.ini file, which is the main configuration file for PHP.
  • Loaded Modules: This section lists all the PHP extensions that are currently loaded.

Conclusion

In conclusion, the phpinfo() function is a valuable tool for PHP developers.

It provides information about your PHP installation, such as the version number, configuration settings, and extensions loaded.

By understanding the output of the phpinfo() function, you can better troubleshoot and optimize your PHP scripts.