phpinfo()

by Vincy. Last modified on July 2nd, 2022.

This function is used to know about the configuration details of PHP installed in our machine. Such detailed information returned by this phpinfo() includes platform information, PHP and server environment, HTTP header information, PHP core details like version and directives status, License information and etc.

The phpinfo() function has an optional argument. If this function is called with no argument, then will display all information. We can check it by executing the following code.

<?php
phpinfo();
?>

We can also request specific details to be displayed to the browser by passing available constants to this function. The following list shows such available options.

  • INFO_GENERAL – This will return information about the platform, compiler, architecture, API and etc.
  • INFO_CREDITS – This option provides a hyperlink that shows details about authors, documentation, QA and the infrastructure team.
  • INFO_CONFIGURATION – Displays PHP core configuration details.
  • INFO_MODULES – shows all available platform modules with their directive, and environment variables.
  • INFO_ENVIRONMENT – will list all environment variables like APPDATA, HOMEPATH and etc.
  • INFO_VARIABLES – Shows an array of predefined global variables.
  • INFO_LICENSE – This shows the access rights statement based on the PHP license.
  • INFO_ALL – Displays all information.

Note: php_info() and php_info(INFO_ALL) both provide same effect on browser.

Use of phpinfo()

This function is used to check if the required support is available with the server or not. For example, in PHP, we can work with the image, if there is GD support.

If we cannot use the image-related functions in a PHP script we can check for the availability of GD support using phpinfo() by,

php_info_modules

Leave a Reply

Your email address will not be published. Required fields are marked *

↑ Back to Top

Share this page