How to check version of php
Categories: PHP
How to Check the Version of PHP You're Running
A Simple Command to Check Your PHP Information
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:
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