在 Windows 命令行上查找 PHP 版本

2022-01-23 00:00:00 windows command version php

我只是想通过 windows 命令输入了解我的 PHP 版本,<代码>C:>php -v但它不起作用.它说 php 不被识别为内部或外部命令.

解决方案

在下面的命令提示符中输入

设置 PATH=%PATH%;C:path	ophp

其中 C:path ophp 是您的 php.exe 文件所在的文件夹.运行后

C:>php -v

你会看到类似的东西

PHP 7.3.6 (cli) (内置: May 29 2019 12:11:00)


更新:

如果您发现当您重新启动计算机时,此解决方案将不再起作用:

如下设置路径:

<块引用>

第 1 步 - 点击 Windows 图标

<块引用>

第 2 步 - 点击 Settings 图标

<块引用>

第三步 - 点击系统

<块引用>

第四步 - 点击About

<块引用>

第五步 - 点击系统信息

<块引用>

第 6 步 - 点击高级系统设置

<块引用>

第 7 步 - 点击环境变量...

<块引用>

第 8 步 - 选择 Path 行,然后点击 Edit

<块引用>

第 9 步 - 点击 New,然后点击 Browse,然后在下一个打开的面板中,您需要选择所需的文件夹在 路径 中.对于本指南的初始前提,我将添加文件夹 C:UsersNewFolderInPath

注意:将您的PHP安装路径(例如:C:Program Filesphp)替换为上述路径♥.

<块引用>

第 10 步 - 单击 OK 并单击您将遇到的每个 OK 按钮以关闭之前的所有窗口.

I just tried to know version of my PHP from windows command typing, C:> php -v But it is not working. It says php is not recognized as internal or external command.

解决方案

In command prompt type below

set PATH=%PATH%;C:path	ophp

Where C:path ophp is the folder where your php.exe file is located. After this run

C:>php -v

than you will see something like

PHP 7.3.6 (cli) (built: May 29 2019 12:11:00) 


UPDATE:

If you find that when you restart your computer, this solution will not work anymore:

Set the Path like as following:

Step 1 - Click on the Windows icon

Step 2 - Click on the Settings icon

Step 3 - Click on System

Step 4 - Click on About

Step 5 - Click on System info

Step 6 - Click on Advanced system settings

Step 7 - Click on Environment variables...

Step 8 - Select Path row and then click Edit

Step 9 - Click New and then click Browse, then in the next panel which will open you need to select the folder you want in the Path. For the initial premise of this guide i will add the folder C:UsersNewFolderInPath

Note: Replace your PHP installed path(e.g:C:Program Filesphp) with the above path ♥.

Step 10 - Click OK and click every OK button you will encounter to close every previous windows.

相关文章