I want to run a .php
file in windows cmd.
I followed this (suggestion)
php is not recognized as an internal command (in Windows)
But it did not work.
I tried this command prompt:
C:\Windows\system32> cd \myfolder
And within myfolder
I did as follows:
C:..\myfolder> php file.php
but I get an error "php is not recognized as internal or external"
But when I try without php
command like this;
C:..\myfolder> file.php
it just opens in notepad, yet I want to run it in cmd
.
How can I do it?
you can for example: set your environment variable path with php.exe folder e.g c:\program files\php
create a script file in d:\ with filename as a.php
open cmd: go to d: drive using d: command
type following command
php -f a.php
you will see the output
You should declare Environment Variable for PHP in path, so you could use like this:
C:\Path\to\somewhere>php cli.php
You can do it like this
It seems your question is very much older. But I just saw it. I searched(not in google) and found My Answer.
So I am writing its solution so that others may get help from it.
Here is my solution.
Unlike the other answers, you don't need to setup environments.
all you need is just to write php index.php
if index.php
is your file name.
then you will see that, the file compiled and showing it's desired output.
Source: Stackoverflow.com