Phpinfo page: The phpinfo()
is a very important function which gives us information about the PHP configuration and installation in our system. Every system is different and hence this information would be different for each of them as well. It can also be used to identify installation and configuration problems.
Phpinfo page in php gives details like platform information, server environment information, PHP details like version, license info, HTTP headers, and the PHP license
. It also includes PHP compilation options, extensions, OS version information, etc. Whenever the phpinfo() function is called without any argument then it will all the information about the PHP configuration in the system, some of the information includes:
Let’s see an example to run the function, just create a file as phpinfo.php
and add the code written below in it:
Now save the file and run it using the PHP server installed in your system. You will get the information displayed like in the image given below:
Other than all the information what if you want specific information like info about variables only or license only. You can do that you just have to pass an argument in the function either as name or their specific value. Every information has given a particular keyword and a value associated with it which we can use in the PHPINFO()
function to get only selective information. Look at the table given below:
Name (constant) | Value | Description |
---|---|---|
INFO_GENERAL | 1 | Information about platform, php.ini location, web system, etc. |
INFO_CREDITS | 2 | Return all the information about the authors, documentation and other credits. |
INFO_CONFIGURATION | 4 | It returns PHP core configuration information. |
INFO_MODULES | 8 | Shows information about all the Loaded modules and their settings. |
INFO_ENVIRONMENT | 16 | Returns all Environment Variable information. |
INFO_VARIABLES | 32 | Shows all predefined variables like GET, POST, etc. |
INFO_LICENSE | 64 | Information about PHP license |
INFO_ALL | -1 | Shows all the information. |
If you have a website live on a server then you can create a phpinfo file in that server to get the information about PHP configuration on that server. It helps in debugging an error sometimes as it contains useful information that one can use in case of any error in the PHP system of the server.
Let’s see the steps to create a phpinfo file on the server:
Step 1: Open your website files using a File Manager or FTP.
Step 2: Open your website’s root directory:
Step 3: Create a new file named phpinfo.php in the root directory. You can create this file anywhere in the subdirectories also but it is easier to locate in the root directory.
Step 4: Add this content into your phpinfo.php file:
Step 5: Save the File.
The file is created. Now you can get all the information about the PHP configuration of your hosting server.
Just go to this URL: http://www.example.com/phpinfo.php
Now all the information about PHP will be displayed on your screen. If you want to look at a particular piece of information, then you can search for it by using the constant name as written in the table above. To start searching try these shortcuts:
A search box will open, now try searching for information like ‘memory’, you will be navigated to the information if found.
Now you’ve learned how to create a phpinfo page and how to check PHP information via in localhost or your hosting control panel. Try to use it in your system or your live server and see the result. Thank You.
Follow Us: