2

I have added this to path:C:\xampp\php. separate by semi colon, & when I put this address (localhost/myfiles/hello.php) on the browser the file was opened properly, so, why cant it be opened in cmd?& I always get this message:Windows cant open this file.

4
  • You need to go into the php directory using cd through cmd to get to it and use DjDarkViper's answer. Commented Aug 1, 2014 at 8:18
  • Not necessarily, because he did mention he added the path to the PHP executable to his PATH global environment variable. This allows him to run any executable in that directory, from anywhere on the system (in this case, php.exe, which Windows CMD automatically adds the .exe aspect, allowing you to just say php) Commented Aug 1, 2014 at 8:21
  • @DJDarkViper good point, didn't see that there Commented Aug 1, 2014 at 8:25
  • The same reason why c:\progra~1 doesn't work, but cd c:\progra~1 works Commented Aug 1, 2014 at 8:36

1 Answer 1

4

command is looking for an absolute path to the file, not an address

$ php ../path/to/myfiles/hello.php

edit

Upon re-reating your question, I could also assume your forgetting to add the php command to the command. Adding the path to PHP in XAMPP allows you to execute the php executable through the command line interface. So you run php and then the switch configs and then the filepath.

Sign up to request clarification or add additional context in comments.

6 Comments

OK, I put this command you gave & get this:couldnt open this file.
if you type php -v what do you see?
PHP 5.5.11 (cli) (built: Apr 8 2014 15:07:14) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
Now I sucseeded opening files by writing this syntax:php C:\xampp\htdocs\myfiles\jim.php my syntax was wrong, Thank you
And yes I was forgetting to add php command to the command. Thank you
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.