在命令提示符中,PHP不被识别为内部或外部命令

问题描述 投票:77回答:8

当我使用php运行命令时出现以下错误

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

当我在以下路径中使用php运行命令时,我没有收到任何错误:

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

为什么我会收到此错误?

'php'不被识别为内部或外部命令,可操作程序或批处理文件。

php cmd exe
8个回答
128
投票

C:\xampp\php添加到PATH环境变量中。

然后关闭命令提示符并重新启动。

这非常重要,因为如果不重新启动命令提示符,则不会反映更改。


80
投票

您需要转到我的电脑 - >属性 - >高级系统设置

现在单击Environment Variables

enter image description here

在路径变量值中添加; C:\ xampp \ php

enter image description here

现在重启命令提示DONE!

注意:确保以管理员身份运行CMD


8
投票

你只需要添加你的PHP文件的路径。如果您使用wamp或尚未将其安装在C驱动器上。

The picture shows how to find the path


7
投票

在PATH环境变量中设置"C:\xampp\php"。然后重启CMD提示符。


5
投票

您的路径配置是否正确?

在Windows中,您可以按照此处所述执行此操作:

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


4
投票

你需要将C:\xampp\php添加到你的PATH Environment Variable,只有在那之后你才能从php外面执行php_home命令行。


2
投票

当我使用PHP运行命令时,我也遇到以下错误,我做了这样的解决方案:

  1. 在桌面上,右键单击“计算机”图标。
  2. 从上下文菜单中选择“属性”。
  3. 单击“高级系统设置”链接。
  4. 单击“环境变量”。在System Variables部分中,找到PATH环境变量并选择它。单击编辑。如果PATH环境变量不存在,请单击“新建”。
  5. 在“编辑系统变量”窗口中,将C:\xampp\php添加到PATH环境变量中。

非常重要的说明:重启命令提示符


0
投票

enter image description here enter image description here

这就是我在MY PC上做的事情我安装了我通常在G中使用的所有软件:partian而不是C:如果我的操作系统是跌倒(赢10),不需要重新安装它们并且浪费时间,那么windows如何工作它更新如果你安装任何新的程序或软件pice,PATH会自动运行,

所以

我必须在这里更新PATH!我经常使用的所有软件

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;G:\HashiCorp\Vagrant\bin;G:\xampp\php;G:\xampp\mysql\bin;G:\Program Files (x86)\heroku\bin;G:\Program Files (x86)\Git\bin;G:\Program Files (x86)\composer;G:\Program Files (x86)\nodejs;G:\Program Files (x86)\Sublime Text 3;G:\Program Files (x86)\Microsoft VS Code\bin;G:\Program Files (x86)\cygwin64\bin

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.