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

Sadikhasan picture Sadikhasan · Jul 8, 2015 · Viewed 258.3k times · Source

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.

Answer

Alive to Die picture Alive to Die · Jul 8, 2015

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

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.