'php.exe' 不是内部或外部命令,也不是可运行的程序或批处理文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8464315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 04:47:13  来源:igfitidea点击:

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

phpwindowsenvironment-variables

提问by Sai Nikhil

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

'php.exe' 不是内部或外部命令,也不是可运行的程序或批处理文件。

Why does that error occur even though I've added PHP to my environment variables?

即使我已将 PHP 添加到我的环境变量中,为什么会发生该错误?

My environment variable PATH is shown below:

我的环境变量PATH如下所示:

C:\Program Files\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\PC ............... Files\QTSystem\;A:\xampp\php\php.exe

C:\Program Files\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\PC ..................... Files\QTSystem\;A:\xampp\php\php.exe

I'm using Windows 7.

我正在使用 Windows 7。

采纳答案by lfxgroove

I think you need to change it to A:\xampp\php\ and just leave it there, then it will search the directory for the file, also: have you tried calling just php instead of php.exe and check that the directory is correct.

我认为您需要将其更改为 A:\xampp\php\ 并将其留在那里,然后它将搜索该文件的目录,还有:您是否尝试过仅调用 php 而不是 php.exe 并检查该目录是否为正确的。

回答by Pekka

A:\xampp\php\php.exe

The PATH environment variable must contain paths only, not file names.

PATH 环境变量必须只包含路径,而不是文件名。

Make that

做那个

A:\xampp\php

回答by Sai Nikhil

it is very easy to do
You need to also add php.exe
Adding this path:
windows key + pause
click on Advance system settings
click Environment Variable
System variables part -> Path -> Edit and the add
C:\wamp\bin\php\php5.3.8;
close you cmd prompt if its open
It's Done!

这很容易做到
你还需要添加 php.exe
添加此路径:
windows键+暂停
点击高级系统设置
点击环境变量
系统变量部分->路径->编辑并添加
C:\wamp\bin\php \php5.3.8;
关闭你的 cmd 提示,如果它打开就
完成了!

回答by Motilal Soni

enter image description here

在此处输入图片说明

View above screen shot for setup enviroment variable in window 7

在窗口 7 中查看上面设置环境变量的屏幕截图

Note:- After setup enviroment variable please restart you computer then its will work fine

注意:-设置环境变量后,请重新启动计算机,然后它会正常工作

回答by Tudor

Shouldn't the last part be: C:\xampp\php\? Unless you remapped your drives, A is the floppy disk. :)

最后一部分不应该是:C:\xampp\php\?除非您重新映射驱动器,否则 A 是软盘。:)

Also, you need to specify the folder, not the exe file itself.

此外,您需要指定文件夹,而不是 exe 文件本身。

回答by Dun0523

My case am Using Bitnami Ruby Stack apache Web server ,

我的情况是使用 Bitnami Ruby Stack apache Web 服务器,

  1. Pressed Windows key + Pause/Break Button
  2. Clicked advanced system settings
  3. Click Environment Variables
  4. Under System variables > edit PATH variable by adding C:\Bitnami\rubystack-1.9.3-24\php
  5. Click Ok to close the Environment Variable window
  6. Close your command prompt if open

    *(Proceed to 7. to confirm if php is installed)

  7. Press Windows Key + R button to open your cmd
  8. Type php -v to view your php version Confirm installed php version
  1. 按下 Windows 键 + 暂停/中断按钮
  2. 单击高级系统设置
  3. 单击环境变量
  4. 在系统变量下 > 通过添加 C:\Bitnami\rubystack-1.9.3-24\php 编辑 PATH 变量
  5. 单击确定关闭环境变量窗口
  6. 如果打开,请关闭命令提示符

    *(进入7.确认是否安装了php)

  7. 按Windows键+ R按钮打开你的cmd
  8. 输入 php -v 查看你的 php 版本 确认安装的php版本

回答by Digisha

Set PHP as environment variable from System as below to run it from CMD

如下从 System 设置 PHP 作为环境变量以从 CMD 运行它

1)Windows key + Pause
2)Click on Advanced system settings
3)Now click on Environment Variables.. button  
4)In system variable section search for Path and edit it as D:\wamp\bin\php\php5.3.13;(If one needs to append it to some already exits value then start path with;)
5)Now open CMD and run command PHP from any path where you don't have PHP installed , in my case it's C drive.
6)We can check above set Path from CMD using Path command also.

回答by Devner

If you have installed WAMP server, then your path can vary. For example, I installed WAMP and the path to my php.exe turned out to be:

如果您安装了 WAMP 服务器,那么您的路径可能会有所不同。例如,我安装了 WAMP,结果我的 php.exe 的路径是:

C:\wamp\bin\php\php5.5.12\php.exe

To make it work, I entered the following path in the PATH variable of the System Variables:

为了使它工作,我在系统变量的 PATH 变量中输入了以下路径:

C:\wamp\bin\php\php5.5.12

Once done, I restarted command prompt and everything worked fine.

完成后,我重新启动命令提示符,一切正常。

So the path can vary depending upon how you installed PHP. If you would like to install WAMP server and have it install other essential packages like PHPMyAdmin, etc. you may do so from: wampserver.com

因此,路径可能因您安装 PHP 的方式而异。如果您想安装 WAMP 服务器并让它安装其他基本软件包,例如 PHPMyAdmin 等,您可以从以下网址进行操作:wampserver.com

回答by Pushpinder Rana

In my case, environment path is C:\ProgramData\Drush\;C:\Program Files (x86)\Drush\Php;and it works for me.

就我而言,环境路径是C:\ProgramData\Drush\;C:\Program Files (x86)\Drush\Php;,它对我有用。

If I simply add C:\xampp\php\dint work for me.

如果我只是C:\xampp\php\为我添加dint 工作。

I hope if someone facing this issue can try this suggestion.

我希望如果有人遇到这个问题可以尝试这个建议。