問題描述
我正在嘗試學習如何從命令行 (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%
環境變量中,或者在 PHP 安裝目錄下工作.
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):
- 右鍵單擊
我的電腦
圖標 - 點擊
屬性
- 點擊左側導航欄中的
Advanced system settings
- 點擊
Advanced
標簽 - 點擊
環境變量
按鈕 - 在
System Variables
部分,選擇Path
(不區分大小寫)并點擊Edit
按鈕 - 在字符串末尾添加分號 (
;
),然后添加 PHP 安裝的完整文件系統路徑(例如C:Program FilesPHP
代碼>) - 繼續點擊
OK
等直到所有對話框消失 - 關閉命令提示符并再次打開
- 已排序
- 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 FilesPHP
) - Keep clicking
OK
etc until all dialog boxes have disappeared - Close your command prompt and open it again
- Sorted
或者,您可以在嘗試運行命令之前運行 cd
,或者像
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?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!