How to Check the PHP Version


2 min read

Check PHP Version

PHP is one of the most used server-side programming languages. There are some important differences between PHP versions, so knowing which version is running on your server might be necessary in some situations.

For example, if you are upgrading your application or installing a new one that requires a specific PHP version before starting with the installation, you’ll need to find out the version of your PHP server.

In this article, we’ll show you how to check what version of PHP your server is running.

Checking PHP version with phpinfo()

The most reliable way of finding out what version of PHP is used for that specific website is to use the phpinfo() function, which prints various information about the PHP server, including its version.

In your website document root directory upload the following PHP file using a FTP or SFTP client:



Open your browser, go to ,and the version of the PHP server will be displayed on your screen:

phpinfo version

Once you find out what PHP version you have, either remove the file or restrict the access to it. Exposing your PHP configuration to the public can pose a security risk to your application.

There is also another function that you can use to find out the PHP version. Unlike phpinfo(), the phpversion() function prints only the version of the PHP server.

echo 'PHP version: ' . phpversion();

Checking PHP version from the Command Line

If you have SSH access to the server, you can use the PHP CLI binary to determine the version of your PHP.

To get the server version, invoke the php binary using the --version or -v option:

php --version

The command will output information about the PHP version and exit. In this example the version of the PHP server is 7.3.11:

PHP 7.3.11-1~deb10u1 (cli) (built: Oct 26 2019 14:14:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies

If there are multiple PHP versions installed on the server, when you run the php command, it will show the version of the default PHP CLI, which may not be the version of PHP used on the website.


Determining the version of the PHP server is a relatively easy task.

In this guide, we have shown several different options about how to find the version of PHP that your server is currently running.

Feel free to leave a comment if you have any questions.