How to Check PHP Version: Step-by-Step Guide

Knowing the version of PHP your server is running is crucial for compatibility and performance reasons, especially when working on web development projects. If your hosting platform doesn’t provide a built-in PHP Info feature, don’t worry! You can easily check the PHP version and other server information by creating a simple phpinfo file in your public_html directory. This blog will guide you through the steps.

Step 1: Access Your Public_HTML Directory

To get started, you’ll need access to your public_html files. Most hosting providers offer a file manager tool that you can use. In this guide, we’re using Hostinger’s File Manager as an example.

  1. Log in to your hosting account and navigate to the File Manager under the Files section in your hPanel.
  2. Once inside the File Manager, locate and enter the public_html directory.

Step 2: Create a PHP Info File

Now that you’re in the public_html directory, it’s time to create the phpinfo file.

  1. Click on the New File button.
  2. Name the file phpinfo.php and press Create.
  3. Scroll down to find your newly created phpinfo.php file within the directory.
  4. Right-click the file and choose Edit.

Step 3: Add PHP Code to the File

With your phpinfo.php file open in the text editor, you’ll need to insert a small piece of PHP code.

  1. Copy and paste the following code into the text editor

<?php
phpinfo();
?>

  1. Press Save to apply the changes.

This code triggers the PHP interpreter to output detailed information about the PHP environment on your server, including the version, configuration settings, and installed extensions.

Step 4: Access the PHP Info Page via Browser

Now that the phpinfo.php file is ready, you can view the PHP information directly through your web browser.

  1. Open your web browser and enter your domain name in the address bar, followed by /phpinfo.php. For example: http://yourdomain.com/phpinfo.php.
  2. Press Enter.

You should now see a detailed page displaying all the information about your server’s PHP configuration, including the version number at the top.

Alternative Method: Using an FTP Client

If you prefer using a text editor on your local machine or if your hosting provider doesn’t have a File Manager, you can create the phpinfo.php file on your computer and upload it to the public_html directory using an FTP client like FileZilla.

  1. Open any text editor (e.g., Notepad, Sublime Text) and create a new file.
  2. Copy and paste the same PHP code
  1. Save the file as phpinfo.php.
  2. Open your FTP client, connect to your server, and navigate to the public_html directory.
  3. Upload the phpinfo.php file to the directory.

Once uploaded, you can access the file through your browser using the same steps mentioned earlier.

Conclusion

Creating a phpinfo file is a straightforward and effective way to check your PHP version and other configuration details directly from your browser. Whether you use your hosting platform’s file manager or an FTP client, this method provides a quick and reliable way to gather essential server information.