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

2023-05-05php开发问题
0

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

问题描述

限时送ChatGPT账号..

我正在尝试学习如何从命令行 (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, 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 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17