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

2021-12-25 00:00:00 exe cmd php

当我使用 php

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

在以下路径中使用 php 运行命令时没有出现任何错误:

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

C:xamppphp>php  //do not got error here

为什么会出现这个错误?

Why I get this error?

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

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

推荐答案

C:xamppphp 添加到您的 PATH 环境变量中.(My Computer->属性->高级系统设置->环境变量->编辑路径)

Add C:xamppphp to your PATH environment variable.(My Computer->properties -> Advanced system setting-> Environment Variables->edit 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.

相关文章