How to Access PHP Commands from the Command Line on Windows
Encountering an error while attempting to execute PHP scripts from the command line? The issue lies in the path configuration.
Solution:
To resolve this problem, it is necessary to include the PHP installation directory in the %PATH% environment variable. Here's how:
-
Right-click on the "My Computer" icon.
- Select Properties from the context menu.
- Navigate to the Advanced tab.
- Click on Environment Variables.
- Under System Variables, locate the Path variable and click Edit.
- Append a semicolon (;) to the end of the string.
- Enter the full path of your PHP installation directory (e.g., C:Program FilesPHP).
- Click OK to save your changes.
- Close the command prompt and restart it.
Your commands should now execute successfully. Alternatively, you can perform the following actions:
- Run cd followed by the PHP installation path before executing your command.
- Invoke your script using the full path of php.exe followed by the script's path (e.g., C:Program FilesPHPphp.exe script.php).
The above is the detailed content of How Do I Run PHP Scripts from the Command Line on Windows?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn