Home  >  Article  >  Backend Development  >  PHP -v is not an internal command: how to fix it

PHP -v is not an internal command: how to fix it

PHPz
PHPzOriginal
2023-04-25 17:28:59884browse

When we develop using PHP, we often encounter a series of strange problems, such as "PHP -v is not an internal command prompt", which brings some inconvenience to the development work. However, this problem is not really a difficult problem and can be easily solved with a simple understanding.

First, let’s understand the cause of this problem. In fact, this prompt message is a prompt given by the Windows system, which means that the executable program corresponding to the "PHP -v" command cannot be found in the current command line window. This is because the Windows system does not automatically add the PHP executable file path to the system environment variables by default. When you enter a command in Windows, the system will first look for the executable program corresponding to the command in the environment variables.

So, how to solve the problem of "PHP -v is not an internal command"? We need to do the following two steps:

Step 1: Find the path to the PHP executable file

We need to find the path to the PHP executable file, which is actually not difficult. In the PHP installation directory, you can find the "php.exe" file, which is the executable file of PHP. You can type the following command in the CMD command line to find the PHP installation path:

where php

This command will display the PHP installation path, such as:

C:\php\php.exe

Step 2: Change the path to the PHP executable file Adding environment variables

After finding the path to the PHP executable file, we need to add the path to the system's environment variables so that Windows can recognize the "PHP -v" command. How to modify environment variables? Please follow the steps below:

  1. First, right-click "This PC" on the desktop and select "Properties";
  2. Select "Advanced System Settings" in the pop-up window;
  3. Click the "Environment Variables" button;
  4. Find the "Path" variable in "System Variables", double-click it to open the editing window;
  5. Add in the last line of the editing window A ";" and then enter the path to the PHP executable file, such as:
;C:\php
  1. Click the "OK" button and close the window.

Now, if we enter the "PHP -v" command in the CMD command line again, we will find that the system can correctly find the PHP executable file.

Summary

The "PHP -v is not an internal command" problem is actually very common, but it is not difficult to solve. Just find the path to the PHP executable file and add it to the system's environment variables to solve the problem. Remember, the correct way to solve a problem is to first find out the cause of the problem, and then solve the problem in a targeted manner.

The above is the detailed content of PHP -v is not an internal command: how to fix it. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn