Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
phpinfo() Function
3.
Steps to Create phpinfo Page
4.
Accessing phpinfo Page on Your Browser
5.
Edit or Rename phpinfo page
6.
Delete phpinfo file
7.
Frequently Asked Questions
7.1.
What is the phpinfo() function in PHP?
7.2.
How can we use the phpinfo() function in PHP?
7.3.
What all information can we view using the phpinfo() function?
7.4.
Do we need to remove the phpinfo() file from the server after use?
8.
Conclusion
Last Updated: Mar 27, 2024

How to Create and Use phpinfo

Author Sohail Ali
1 upvote

Introduction

Often when we run our software on a server, many system errors halt the process. This can happen if your configuration does not meet the specific system requirements. Finding even the basic information about your PHP configuration can be tricky. But we can create a single PHP info file showing us all details about our PHP configuration.

How to Create and Use phpinfo

In this blog, we will discuss how to create and use the phpinfo file using your hosting control panel. So without any further wait, let’s start learning!

phpinfo() Function

PHP provides us with a built-in function called phpinfo() which displays the details about the current PHP version and its configuration installed on our system. It is a very useful debugging tool as it contains every EGPCS (Environment, GET, POST, Cookie, Server) data.

Syntax:

phpinfo(int $flags = INFO_ALL): true
You can also try this code with Online PHP Compiler
Run Code

 

Parameters:

flag: It is an optional parameter which displays specific information. The value of the flag can be any of the following:

Value

Description

INFO_GENERAL It displays the configuration line, built date, web server, etc.
INFO_CREDITS It displays the PHP Credits.
INFO_CONFIGURATION It displays the current, local and master values for PHP directives.
INFO_MODULES It displays the loaded modules and their settings.
INFO_ENVIRONMENT It displays the info about the environment variable.
INFO_VARIABLES It displays all the predefined variables from EGPCS.
INFO_LICENSE It displays the info on the PHP License.
INFO_ALL It is used to display all the above information.

Steps to Create phpinfo Page

Follow the below steps to create a phpinfo page for your site.

Step 1: Create a phpinfo file on your device. Open your preferred text editor and write down the below code.

PHP code

Now save this file with the name info.php on your device.
 

Step 2: Open up any FTP client and connect your site’s server with your credentials.

FTP client interface


Step 3: In the file section, click on the Online File Manager

online file manager


Step 4: Now go to the htdocs folder or create any custom folder and click on the upload button.

uploading phpinfo file


Step 5: Upload the info.php file we created using the text editor. 

final output

Congratulations! You have successfully added the php info page to your site.

Accessing phpinfo Page on Your Browser

Now that you have uploaded your phpinfo file on your server, it will be available publicly. Anyone can view your phpinfo page by adding /info.php to the end of your site’s domain name.

Accessing phpinfo page on browser

Now if you didn’t specify any parameter, it would return the complete PHP information page, which is quite long. In order to locate the specific file details, you can use the Find function on your browsers by clicking CTRL + F on your computer.

locate specific file details on browser

Edit or Rename phpinfo page

You can edit the uploaded php.info file as well as rename it even after uploading it. Just right-click on the php.info file, and you can see various options available for your file.

edit or rename phpinfo page

Delete phpinfo file

As your info.php file is available publicly, it is prone to many attacks. Attackers may use various tools/bots to exploit your sensitive data. Therefore, it is best to delete the info.php file once you are done using it. 

In order to delete the file, click info.php file > delete > confirm. 

delete phpinfo file

This will delete the uploaded info.php file from your FTP client.

Frequently Asked Questions

What is the phpinfo() function in PHP?

The phpinfo() method is a built-in function available in PHP that is used to display information about the PHP environment.

How can we use the phpinfo() function in PHP?

In order to use the phpinfo() function, we need to make a call to it in our PHP script file.

What all information can we view using the phpinfo() function?

Using the phpinfo() function, we can view the PHP version, server info, system paths, and many more.

Do we need to remove the phpinfo() file from the server after use?

Yes, we should remove the phpinfo() file when we are done using it by simply deleting the file from the server's directory.

Conclusion

This article discusses the topic of how to create and use phpinfo. We discussed the phpinfo() function along with the steps to create and display it on our browser. We hope this blog has helped you enhance your knowledge of how to create and use phpinfo. If you want to learn more, then check out our articles.

Refer to our Guided Path to upskill yourself in DSACompetitive ProgrammingJavaScriptSystem Design, and many more! If you want to test your coding ability, you may check out the mock test series and participate in the contests hosted on Coding Ninjas!

But suppose you have just started your learning process and are looking for questions from tech giants like Amazon, Microsoft, Uber, etc. In that case, you must look at the problemsinterview experiences, and interview bundles for placement preparations.

However, you may consider our paid courses to give your career an edge over others!

Happy Learning!

Live masterclass