If you're interested in adding new features to your website or trying to debug a programming issue, you'll need to check which PHP version your server is using. You can do this by running a simple PHP file on the server, or by checking the PHP version installed on your local machine using Command Prompt on Windows or Terminal on Mac.
Steps
Server

Open a code or text editor. You can use Notepad or TextEdit, but avoid using word processors like Microsoft Word.

Enter the code below. When executed on your server, this small piece of code will return the PHP version information.
<?php echo 'Current PHP version: ' . phpversion(); ?>

Save as a PHP file. Click on "File" → "Save as" and give the file a name. Add the .php extension to the filename. Choose a simple name like version.php.

Create a more detailed report (optional). The file above will show you the current PHP version. However, if you want more information, such as system details, release date, available commands, API info, etc., you can use the phpinfo() command. Save the file with the name info.php.
<?php phpinfo(); ?>

Upload your file(s) to the server. You may need to use an FTP client program or upload via your server's management control panel. Place the file in the root directory on your server.
- Refer to articles on how to upload files to your server.

Open the file in your browser. Once the file is uploaded to the server, you can access it via your browser. Find the file's location on the server. For example, if it's in the root directory, go to www.yourdomain.com/version.php.
- To view all the details, go to www.yourdomain.com/info.php.
Local PHP version

Open Command Prompt or Terminal. If PHP is installed locally, you can use Command Prompt or Terminal to check the version number. You can also follow this method if you are using SSH to remotely connect to a server via the command line.
- Windows – Press ⊞ Win+R and type cmd.
- Mac – Open Terminal from the Utilities folder.
- Linux – Open Terminal from the screen or by pressing Ctrl+Alt+T.

Enter the command to check the PHP version. When you run this command, it will display the installed PHP version.
- Windows, Mac, Linux – php -v

Fix the issue of the PHP version not appearing on Windows. A common problem for Windows users is that PHP is not in the system path, leading to the error ‘php.exe’ is not recognized as an internal or external command, operable program or batch file.
- Find your php.exe file. It is usually located at C:\php\php.exe, but you may have changed it during installation.
- Type set PATH=%PATH%;C:\php\php.exe and press ↵ Enter. Update the actual location if it is not currently in this path.
- Run php -v again. Now you should be able to see the version number.
