To run the PHP code with CMD, first configure the computer:
1. Right-click Computer-Properties-Advanced system settings-environment variables, we need to add environment variables.
2. Under administrator user variable (U) Click New, Pop-up dialog box, variable name (N) write: php_home, variable Value (V) for your PHP program installation path, for example my is: D:\wamp\bin\php\php5.5.12\ Php.exe, click OK after writing.
3. Locate path under System variable (S), click Edit, copy the variable value CTRL + C to the text document, then add the semicolon (if there is a semicolon), add the Php.exe folder path, and finally add a semicolon.
Then select Copy to paste into the variable value (V) and click OK.
4. Restart your computer after adding environment variables.
5. Open cmd, for example we want to run the WWW directory under 22.php this file:
After c:users\administrator> input PHP, space, and then enter d:\wamp\www\22.php, you can run this PHP file on the Web page;
Or C:users\administrator>php-f d:\wamp\www\22.php This is also possible.
You can also enter php-v (note there are spaces in the middle) to view PHP version information.
Open a 22.php file:
C:users\administrator> D:
D\>CD Wamp
D:\WAMP>CD www
d:\wamp\www>22.php
This can be opened in the DW software 22.php this file, not run. (Note space)
Run PHP code with cmd