Run .php file in Windows Command Prompt (cmd)
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
If running Windows 10:
- Open the start menu
- Type
path
- Click Edit the system environment variables (usually, it's the top search result) and continue on step 6 below.
If on older Windows:
Show Desktop.
Right Click My Computer shortcut in the desktop.
Click Properties.
You should see a section of control Panel - Control Panel\System and Security\System.
Click Advanced System Settings on the Left menu.
Click Enviornment Variables towards the bottom of the System Properties window.
Select PATH in the user variables list.
Append your PHP Path (C:\myfolder\php) to your PATH variable, separated from the already existing string by a semi colon.
Click OK
Open your "cmd"
Type PATH, press enter
Make sure that you see your PHP folder among the list.
That should work.
Note: Make sure that your PHP folder has the php.exe. It should have the file type CLI. If you do not have the php.exe, go ahead and check the installation guidelines at - http://www.php.net/manual/en/install.windows.manual.php - and download the installation file from there.