Home > Backend Development > PHP Problem > How to solve the error 'php is not an internal or external command' under windows

How to solve the error 'php is not an internal or external command' under windows

PHPz
Release: 2023-03-23 14:26:01
Original
2239 people have browsed it

For users who have just started using PHP, they may be confused if they encounter the "php is not an internal or external command" problem in the Windows operating system. This error is usually caused by the system not recognizing the path to PHP.

In this article, I will provide you with some possible causes and solutions to this problem to help you solve this problem quickly.

  1. PHP path is not set correctly

In Windows systems, if you want to run PHP programs under the command line, you need to ensure that PHP The path is correctly set in the system's Path environment variable. If it is not set up correctly then you will get "php is not an internal or external command" error.

To set the PHP path, you need to perform the following steps:

  • Open Control Panel

  • Select "System and Security"

  • Select system

  • Select advanced system settings

  • Select environment variables

  • Find Path in the system variable

  • Click "Edit"

  • Add the path to PHP in the variable value

    For example: C:\php\php.exe

  1. The PHP file saving path is incorrect

If you have set up the PHP path correctly and you enter php in the command line, but still encounter the "php is not an internal or external command" error, then the problem may be caused by an incorrect path to save the PHP file.

To resolve this issue, you need to ensure that the PHP files are saved in the correct directory and that the correct paths are used to access these PHP files from the command line. For example, if you save a PHP file in the C:\php\ directory, you can access this file from the command line using the following command: C:\php\php.exe C:\php\myfile.php.

  1. PHP is not installed correctly

If the above two solutions cannot solve the problem, then the problem may be caused by PHP not being installed correctly. In this case, you need to reinstall PHP and confirm that the path and directory where the PHP files are saved are set correctly.

If you have followed the above steps and still cannot solve the problem, the problem may be due to other reasons. In this case, you can check the system logs for more information, or ask for help in the forum.

Summary

When you encounter the error "php is not an internal or external command" in a Windows system, you first need to check whether the PHP path is set correctly. If the path is correct, then the problem may be caused by an incorrect path to save the PHP file or PHP not being installed correctly. No matter what goes wrong, you can fix it by debugging and asking for help.

The above is the detailed content of How to solve the error 'php is not an internal or external command' under windows. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template