问题描述
我正试图学习如何从命令行(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, selectPath
(case-insensitive) and clickEdit
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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!