In Linux platforms like Ubuntu executing php through terminal is easy. All you need is to install the
php5-cli package. After the package installed,
php command is already available in terminal.
In Windows, I find it easy using the WAMP Server. On my Windows 7 OS I already installed the 64-bit WAMP version 2.1 and will make use of it. During this post the WAMP isntallation comes with Php version 5.3.4.
We will going to add the the directory to php.exe
C:\wamp\bin\php\php5.3.4 in the PATH variable under System Variables.
To add, right click on Computer>Properties and click on Advanced System Setings.
Then, System Properties will be displayed and on the Advanced tab click on Environment Variables…
After, Environment Variables window will be displayed and on the System Variables click on path and then edit.
On the Edit System Variable add our path to php.exe C:\wamp\bin\php\php5.3.4 on the Variable value as shown.
And click OK on all windows.
To test, lets create a hello-world.php that contains the command.
<?php echo 'Hello World'; ?>
Save it on Desktop. Then, open command prompt and change the directory to Desktop and execute php hello-world.php.