What Version of PHP Am I Running?

A Simple Way to Check Your PHP Version

Michael DeLeon/E+/Getty Images

If you can't get something to work, and think it might be because you have the wrong version of PHP, there is a really simple way to check the current version. Below are instructions for checking both the server version and the locally installed version.

Different versions of PHP may have different default settings, and in the case of newer versions, might have new functions. If a PHP tutorial is giving instructions for a particular version of PHP, it's important to understand how to check the version you have installed.

How to Check the PHP Version

Simply running the phpinfo () function will not only tell you your PHP version but an abundance of information about all your PHP settings.

Here is an example:

<?php phpinfo() ?>

That's it! Just put that single line of code in a PHP file, and run it on your server to get all the information you need.

Below is how to check the locally installed version of PHP. You can run this in Command Prompt in Windows or Terminal for Linux/macOS.

php -v

Is the PHP Version Not Showing in Windows?

The most common reason for the version of PHP not showing up is if the path to PHP is not setup with Windows. You might see the error ‘php.exe’ is not recognized as an internal or external command, operable program or batch file.

In a Command Prompt, type the following command, where the path after "C:" is the path to PHP (yours may be different):

set PATH=%PATH%;C:\php\php.exe