How to Check Your Website’s PHP Version

Are you curious about what PHP version your website is running? There are a few different ways to check which PHP version your website is running. In this blog post, we will show you 4 methods.

Your website’s PHP version affects both the security and performance of your site. Newer versions of PHP offer improved security features and faster performance. Keeping your website up-to-date with the latest PHP version is therefore important for both your visitors and your business.

Use the phpinfo() method

The phpinfo() method contains information about your server’s configuration, including the PHP version. To access it, create a new file called phpinfo.php in your website’s root directory and add the following line of code:

<?php 
    phpinfo();
?>

Save the file and then open it in your browser. You should see a page similar to the one below, which indicates that the site is running PHP version 7.3.27.

As you can see from the image above, the phpinfo() function will also give you information on other aspects of your server’s configuration, such as the operating system, PHP extensions, and more.

Command line

If you don’t want to create a PHP file to run functions, you can also check your PHP version using the command line. To do this, SSH into your server and run the following command:

php -v

This will output something like the following, which shows that the server is running PHP version 7.0.15.

Use phpversion() method or PHP_VERSION constant

The phpversion() method is a great way to check which version of PHP is currently running on your server. It returns a string containing the version number of the currently running PHP parser or extension. For example, if you’re running PHP 7.0, the string returned would be “7.0”.

echo 'PHP version is: '.phpversion();
//PHP version is: 7.1.1-1

The most fundamental method to do it is by calling PHP_VERSION constant and not making any function calls, which is both efficient and safe.

echo 'The version is '. PHP_VERSION;
//The version is 7.1.1-1

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close