How Do I Run PHP Scripts from the Command Line on Windows?

Mary-Kate Olsen
Release: 2024-10-31 17:59:39
Original
412 people have browsed it

How Do I Run PHP Scripts from the Command Line on Windows?

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:

  1. Right-click on the "My Computer" icon.
  2. Select Properties from the context menu.
  3. Navigate to the Advanced tab.
  4. Click on Environment Variables.
  5. Under System Variables, locate the Path variable and click Edit.
  6. Append a semicolon (;) to the end of the string.
  7. Enter the full path of your PHP installation directory (e.g., C:Program FilesPHP).
  8. Click OK to save your changes.
  9. 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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!