Here's How to Check the Version of PHP You're Running

A Simple Command to Check Your PHP Information

Senior man using laptop at patio table
Paul Bradbury/Getty Images

If you can't get something to work and think it might be because you have the wrong version of PHP, there's a really simple way to check the current 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

Running a simple PHP file will not only tell you your PHP version but an abundance of information about all your PHP settings. Just put this single line of PHP code in a blank text file and open it on the server:

<?php phpinfo() ?>

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

Here's an example output:

PHP 5.6.35 (cli) (built: Mar 29 2018 14:27:15)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Is the PHP Version Not Showing in Windows?

Given that you actually are running PHP on your web server, the most common reason for the version of PHP not showing up is if the path to PHP is not set up with Windows.

You might see the error like this if the correct environment variable isn't configured:

‘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

Format
mla apa chicago
Your Citation
Bradley, Angela. "Here's How to Check the Version of PHP You're Running." ThoughtCo, Feb. 16, 2021, thoughtco.com/what-version-of-php-running-2694207. Bradley, Angela. (2021, February 16). Here's How to Check the Version of PHP You're Running. Retrieved from https://www.thoughtco.com/what-version-of-php-running-2694207 Bradley, Angela. "Here's How to Check the Version of PHP You're Running." ThoughtCo. https://www.thoughtco.com/what-version-of-php-running-2694207 (accessed March 28, 2024).