PHP is not recognized as an internal or external c

2019-01-10 13:35发布

I got the following error when I run a command with php

C:\xampp\htdocs>php
'php' is not recognized as an internal or external command,
operable program or batch file.

I don't get any error when I run the command with php in following path:

C:\xampp\php>php  //do not got error here

Why I get this error?

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

标签: php cmd exe
8条回答
狗以群分
2楼-- · 2019-01-10 14:13

Is your path correctly configured?

In Windows, you can do that as described here:

http://www.computerhope.com/issues/ch000549.htm

查看更多
Root(大扎)
3楼-- · 2019-01-10 14:13

I also got the following error when I run a command with PHP, I did the solution like that:

  1. From the desktop, right-click the Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced system settings link.
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
  5. In the Edit System Variable window, Add C:\xampp\php to your PATH Environment Variable.

Very important note: restart command prompt

查看更多
Luminary・发光体
4楼-- · 2019-01-10 14:14

You need to Go to My Computer->properties -> Advanced system setting

Now click on Environment Variables

enter image description here

Add ;C:\xampp\php in path variable value

enter image description here

Now restart command prompt DONE!

Note: Make sure you run CMD via run as administrator

查看更多
▲ chillily
5楼-- · 2019-01-10 14:16

You just need to a add the path of your PHP file. In case you are using wamp or have not installed it on the C drive.

The picture shows how to find the path

查看更多
家丑人穷心不美
6楼-- · 2019-01-10 14:18

Add C:\xampp\php to your PATH Environment Variable.

Then Close your Command Prompt And Restart Again.

It's very important because if you didn't restart you command prompt then changes will not be reflected.

查看更多
仙女界的扛把子
7楼-- · 2019-01-10 14:19

Set "C:\xampp\php" in your PATH Environment Variable. Then restart CMD prompt.

查看更多
登录 后发表回答