PHP stands for “PHP Hypertext Preprocessor” and it is a scripting language that is used to build dynamic web pages. There are many reasons why you might want to know what version of PHP your website is running, including compatibility issues with your site or the plugins you are using. In this article, we will walk through how to check the PHP version on your server.
Why should we need to know PHP version?
There are a number of reasons why you might want to know the PHP version running on your website. One reason is if you have been having compatibility issues with plugins or other scripts used in conjunction with your site. Another reason for checking the version could be because there was an update released by the PHP team and it may not work as well as expected until they release another update that fixes any bugs.
Understanding how to check the current PHP version, can also help when troubleshooting installations where things don’t seem right but without knowing whether it’s due to misconfiguration or outdated software versions, one cannot easily diagnose what needs fixing before moving forward. Lastly, some hosting providers only offer certain levels of support based on their understanding of which versions of PHP their hosting platform can support.
3 ways to check current PHP version
Use command line
To check which version of PHP is installed on your system, open up a terminal window and type this command:
php -v or
And then read off the output that appears in return. It should look something like this (the number following it will be incremented each time you run it): “PHP X.Y.Z” means that the current version running on your server is an older one than what’s recommended by WordPress or other programs you may use for development purposes.
Use phpinfo() function
phpinfo() is a built-in PHP function which prints out information about the PHP installation on your server. This can be used to identify the current version, as well as other configuration settings of an installed PHP environment such as memory limit, session storage and more.
To use this function, you need to add it to a PHP file.
<?php phpinfo(); ?>
Running the file on your server will return all sorts of useful data that you’ll need in order to find out what’s wrong with your hosting provider or plan if any number is not set up correctly.
phpversion() is another function that returns PHP version. It only displays the version number and nothing else. It is suitable to be used if you only need to know the version number.
<?php echo 'My PHP version is: '.phpversion(); ?>
Output: “My PHP version is: 7.3.27”