PHP 在命令提示符中未被识别为内部或外部命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31291317/
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
PHP is not recognized as an internal or external command in command prompt
提问by Sadikhasan
I got the following error when I run a command with php
当我运行命令时出现以下错误 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:
当我php
在以下路径中运行命令时,我没有收到任何错误:
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' 不是内部或外部命令,也不是可运行的程序或批处理文件。
回答by Anant Singh---Alive to Die
Add C:\xampp\php
to your PATH
environment variable.
添加C:\xampp\php
到您的PATH
环境变量。
Then close your command prompt and restart again.
然后关闭命令提示符并再次重新启动。
Note:
笔记:
It's very important to close your command prompt and restart again otherwise changes will not be reflected.
关闭命令提示符并重新启动非常重要,否则将不会反映更改。
回答by Prince Patel
You need to Go to My Computer->properties -> Advanced system setting
您需要转到我的电脑-> 属性-> 高级系统设置
Now click on Environment Variables
现在点击环境变量
Add ;C:\xampp\phpin pathvariable value
在路径变量值中添加;C:\xampp\php
Now restart command prompt DONE!
现在重新启动命令提示符完成!
Note:Make sure you run CMD via run as administrator
注意:确保以管理员身份运行 CMD
回答by Progga Ilma
回答by Vikas
Set "C:\xampp\php"
in your PATH Environment Variable. Then restart CMD prompt.
设置"C:\xampp\php"
在你的PATH环境变量。然后重新启动 CMD 提示。
回答by Raja
You need to add C:\xampp\php
to your PATH Environment Variable
, Only after then you would be able to execute php
command line from outside php_home
.
您需要添加C:\xampp\php
到您的PATH Environment Variable
, 只有在此之后您才能php
从外部执行命令行php_home
。
回答by user5093637
Is your path correctly configured?
你的路径配置正确吗?
In Windows, you can do that as described here:
在 Windows 中,您可以按照此处所述进行操作:
回答by Udhav Sarvaiya
I also got the following error when I run a command with PHP
, I did the solution like that:
当我用 运行命令时PHP
,我也遇到了以下错误,我是这样解决的:
- From the desktop, right-click the Computer icon.
- Choose Properties from the context menu.
- Click the Advanced system settings link.
- 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.
- In the Edit System Variable window, Add
C:\xampp\php
to your PATHEnvironment Variable.
- 在桌面上,右键单击计算机图标。
- 从上下文菜单中选择属性。
- 单击高级系统设置链接。
- 单击环境变量。在 System Variables 部分,找到 PATH 环境变量并选择它。单击编辑。如果 PATH 环境变量不存在,请单击新建。
- 在“编辑系统变量”窗口中,添加
C:\xampp\php
到您的PATH环境变量。
Very important note: restart command prompt
非常重要的提示:重启命令提示符
回答by Abu Bakr
Here what I DO on MY PC I install all software that i usually used in G: partian not C: if my operating system is fall (win 10) , Do not need to reinstall them again and lost time , Then How windows work it update PATH automatic if you install any new programe or pice of softwore ,
这是我在我的 PC 上所做的,我安装了我通常在 G 中使用的所有软件:partian 而不是 C:如果我的操作系统失败(win 10),不需要再次重新安装它们并浪费时间,那么 Windows 是如何工作的呢?如果您安装任何新程序或软件,路径自动,
SO
所以
I must update PATH like these HERE! all my software i usually used
我必须在这里更新 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