如何在Windows上使用命令行访问PHP

如何在Windows上使用命令行访问PHP

本文介绍了如何在Windows上使用命令行访问PHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图学习如何从命令行(CLI)访问PHP脚本

I am trying to learn how to access PHP scripts from the command line (CLI)

以下是我尝试的图片,请帮助。我正在运行Windows 7

Below is an image from my attempt, please help. I am running Windows 7

推荐答案

您需要将您的PHP安装目录添加到%PATH%环境变量

You need to add your PHP installation directory to the %PATH% environment variable, or work from the PHP installation directory.

要将其添加到路径(最佳方法 - 为Windows 7编辑):

To add it to path (The best approach - Edited for Windows 7):


  • 右键单击我的电脑图标

  • 单击属性

  • 从左侧导航单击高级系统设置 li>
  • 点击高级标签

  • 点击环境变量按钮

  • 系统变量部分,选择路径 -insensitive),然后点击编辑按钮

  • 添加分号(; )到字符串的末尾,然后添加您的PHP安装的完整文件系统路径(例如 C:\Program Files\PHP

  • 继续单击确定等,直到所有对话框都消失

  • 关闭命令提示符, li>
  • 已排序

  • Right-click on a My Computer icon
  • Click Properties
  • Click Advanced system settings from the left nav
  • Click Advanced tab
  • Click Environment Variables button
  • In the System Variables section, select Path (case-insensitive) and click Edit button
  • Add a semi-colon (;) to the end of the string, then add the full file system path of your PHP installation (e.g. C:\Program Files\PHP)
  • Keep clicking OK etc until all dialog boxes have disappeared
  • Close your command prompt and open it again
  • Sorted

或者,您也可以执行 cd< PHP installation path> ; 之前,你尝试运行你的命令,或调用您的脚本像< FULL文件系统路径php.exe> < path to script>

Alternatively, you can run cd <PHP installation path> before you try and run you command, or call your script like <FULL file system path of php.exe> <path to script>

这篇关于如何在Windows上使用命令行访问PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 07:59