top of page


The Impact of PHP Version and How to Check it

Using an old version of PHP can lead to security vulnerabilities and other issues. Here's how you can check your PHP version.

How to Check Your PHP Version

php -v

If you see version information like the following, you're good to go.

PHP 8.2.1 (cli) (built: Jan 11 2023 07:28:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.1, Copyright (c) Zend Technologies
with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans

You might think, "I already know this command, but it's not showing me the version!". In that case, you might be executing it from the wrong directory.

'php' is not recognized as an internal or external command, operable program or batch file.

The Location to Execute

Here's how to address it, based on your operating system.

Linux / Windows Environment

First, determine your environment.

Linux: Open a terminal and run php -v from the relevant directory.

Windows: Open Command Prompt or PowerShell and run php -v from the relevant directory.

If You're Confused About "The Relevant Directory"

"The relevant directory" refers to the directory where PHP is installed. Obviously, PHP commands can't be executed from a location where PHP isn't installed.

To find PHP's installation location, you can use the following commands.


# Terminal commands to find PHP installation location
find / -type f -name "php" -executable -print


# Command in Terminal to find PHP installation location
dir /s /b php.exe
# Command in PowerShell to find PHP installation location
where.exe php

Executing these commands will display the path to the PHP installation location.

Once You've Found PHP's Location

For example, if the path /usr/local/bin/php is displayed when you run the command above, you can navigate to the installation location by excluding /php from the path.

# Example command to navigate to the PHP installation location
cd /usr/local/bin

After this, running php -v will correctly display the PHP version. However, it can be annoying to navigate to this directory every time.

Making PHP Executable from Anywhere

Once you've located the PHP installation directory, you can add it to your PATH. This allows you to execute PHP from any directory.


Add the path by executing the following command in the terminal:

export PATH=$PATH:[PHP installed path]

For instance, if PHP is installed in /usr/local/bin, you would use the following command.

This path is the path we found in the previous step.

export PATH=$PATH:/usr/local/bin


You can add the path by modifying the system environment variables.

1. Search for and open "Edit the system environment variables".

2. Click on the "Environment Variables" button.

3. In the "System Variables" section, select the "Path"and click "Edit".

4. Click "New" and add the PHP installation path.

5. Save the changes and close the dialog.

This addition to the environment variable PATH ensures that PHP can be executed from any directory, making your PHP usage more convenient. Enjoy a smoother PHP experience!

This blog post is translated from a blog post written by Tamaki on our Japanese website Beyond Co..

Recent Posts

See All


bottom of page