How to Check the PHP Version

PHP, one of the most commonly used programming languages for building websites and applications, is often utilized in popular Content Management Systems (CMS) like WordPress, Joomla, and ModX. Following the installation of any CMS, you might need to verify your PHP version to understand its specific functionalities. Below, we describe two ways to check your PHP version.

Please note: To check the PHP version, you’ll need server access.

Method #1: Checking PHP Version via the command line

1. Connect to your server using SSH.

2. Execute the following command:

php -v

This command should generate an output similar to:

PHP 7.3.21 (cli) (built: Aug  4 2020 11:52:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.21, Copyright (c) 1998-2018 Zend Technologies

The first line of the output reveals the installed PHP version, which in this case, is PHP 7.3.21.

Method #2: Checking PHP Version via a PHP File

1. Connect to your server via FTP or SSH.

2. In your server’s root directory, create a new PHP file, for instance, phpinfo.php. Inside this file, use the phpinfo() function:

<?php
phpinfo();
?>

3. In your web browser, navigate to https://your-server/phpinfo.php (be sure to replace “your-server” with your server’s IP address or domain name). The installed PHP version will be displayed on the first line of the resulting page.

For example, the output might show that the PHP version is 7.4.3.

Check the PHP version

Note: After verifying your PHP version, remember to delete or secure the phpinfo.php file. This file contains detailed server information and could pose a security risk if left publicly accessible.

Conclusion

Developing with PHP and need an efficient cloud solution? Gcore’s offerings have you covered.

  • Web Application Security enhances the security of your PHP applications by protecting them from web-based threats, ensuring a secure experience for your website’s visitors.
  • Managed Database for PostgreSQL provides a hassle-free database management solution, making it easier to handle data-driven operations in your PHP applications.
  • Virtual Instances.
  • Bare Metal offers the ultimate in server power and performance with an entire server dedicated to your needs alone.

Start coding with PHP on Gcore today

Subscribe and discover the newest
updates, news, and features

We value your inbox and are committed to preventing spam