I would like to post a solution for the following queries which are important for the programmer to execute the PHP script from command line.
Follow the steps to set Environment Variable
My OS: Windows 7
- Go to properties of My Computer
- Click on Advanced System Settings in Left side
- Select Advanced tab and click on Environment Variables
- In the System Variables search for Path Variable, select that one and click edit
- Add the semicolon(;) at the end of the line, and paste the PHP path C:\wamp\bin\php\php5.4.16
- Save all changes by clicking OK.
- open command prompt and go the folder where the PHP file exists, then execute by using the following command.
- D:\>php file-name.php (press Enter)