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

0 votes

I am getting this error when I run the command in PHP:

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

When I run the command in this path, it doesn't give an error.

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

Why am I getting this error? and how can I solve this?

May 7, 2022 in PHP by narikkadan
• 86,360 points
3,773 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Solution

  • Go to My computer > Advanced system settings > Environment variable > Path 
  • Add C:\xampp\php to your PATH environment variable.
  • Close your command prompt and restart again.
  • Please note that it's important to restart otherwise the changes won't get reflected.

I hope this helps.

answered May 8, 2022 by Kichu
• 19,040 points

edited Mar 5, 2025
0 votes

Solution

  • Go to My computer > Advanced system settings > Environment variable > Path. 
  • Add C:\xampp\php to your PATH environment variable.
  • Close your command prompt and restart again.
  • Please note that it's important to restart otherwise the changes won't get reflected.

I hope this helps.

answered May 8, 2022 by Kichu
• 19,040 points

edited Mar 5, 2025

Related Questions In PHP

0 votes
1 answer

How to check if php session is already started or not?

Hello kartik, Use session_id(), it returns an empty string ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,800 points