PHP is not recognized as an internal or external command in command prompt

限于喜欢 提交于 2019-12-17 08:17:11

问题


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.


回答1:


Add C:\xampp\php to your PATH environment variable.

Then close your command prompt and restart again.

It is very important because if you do not restart your command prompt then changes will not be reflected.




回答2:


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

Now click on Environment Variables

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

Now restart command prompt DONE!

Note: Make sure you run CMD via run as administrator




回答3:


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.




回答4:


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




回答5:


Is your path correctly configured?

In Windows, you can do that as described here:

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




回答6:


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.




回答7:


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




回答8:


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 ,

SO

I must update PATH like these HERE! all my software i usually used

%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



来源:https://stackoverflow.com/questions/31291317/php-is-not-recognized-as-an-internal-or-external-command-in-command-prompt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!