在Windows命令提示符(cmd)中运行.php文件 [英] Run .php file in Windows Command Prompt (cmd)

查看:149
本文介绍了在Windows命令提示符(cmd)中运行.php文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Windows cmd中运行.php文件. 我遵循了这个(建议) php未识别为内部命令(在Windows中)

I want to run a .php file in windows cmd. I followed this (suggestion) php is not recognized as an internal command (in Windows)

但是它没有用.

我尝试了以下命令提示符:
C:\Windows\system32> cd \myfolder

I tried this command prompt:
C:\Windows\system32> cd \myfolder

myfolder中,我做了如下操作:
C:..\myfolder> php file.php
但出现错误"php不被识别为内部或外部"

And within myfolder I did as follows:
C:..\myfolder> php file.php
but I get an error "php is not recognized as internal or external"

但是当我尝试不使用php这样的命令时;
C:..\myfolder> file.php
它只是在记事本中打开,但我想在cmd中运行.
我该怎么办?

But when I try without php command like this;
C:..\myfolder> file.php
it just opens in notepad, yet I want to run it in cmd.
How can I do it?

推荐答案

如果运行Windows 10:

  1. 打开开始菜单
  2. 键入path
  3. 点击 编辑系统环境变量 (通常是搜索结果的顶部),然后继续执行下面的步骤 6 .
  1. Open the start menu
  2. Type path
  3. Click Edit the system environment variables (usually, it's the top search result) and continue on step 6 below.

如果在旧版Windows上:

  1. 显示桌面.

  1. Show Desktop.

右键单击桌面上的 我的电脑 快捷方式.

Right Click My Computer shortcut in the desktop.

单击 属性 .

Click Properties.

您应该看到控制面板的一部分- 控制面板\系统和安全性\系统 .

You should see a section of control Panel - Control Panel\System and Security\System.

在左侧菜单上单击 高级系统设置 .

Click Advanced System Settings on the Left menu.

系统属性窗口的底部单击 环境变量 .

Click Enviornment Variables towards the bottom of the System Properties window.

在用户变量列表中选择 PATH .

Select PATH in the user variables list.

将您的PHP路径(C:\ myfolder \ php)附加到PATH变量中,并用分号将其与现有字符串分开.

Append your PHP Path (C:\myfolder\php) to your PATH variable, separated from the already existing string by a semi colon.

单击确定"

打开您的"cmd"

键入PATH,然后按Enter

Type PATH, press enter

确保在列表中看到您的PHP文件夹.

Make sure that you see your PHP folder among the list.

应该可以.

注意:确保您的PHP文件夹包含php.exe.它的文件类型应为CLI.如果您没有php.exe,请继续检查安装指南--

Note: Make sure that your PHP folder has the php.exe. It should have the file type CLI. If you do not have the php.exe, go ahead and check the installation guidelines at - http://www.php.net/manual/en/install.windows.manual.php - and download the installation file from there.

这篇关于在Windows命令提示符(cmd)中运行.php文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆