在 Windows 命令行上查找 PHP 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15517718/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Find PHP version on windows command line
提问by ntf
I just tried to know version of my PHP from windows command typing,
C:\> php -vBut it is not working. It says php is not recognized as internal or external command.
我只是试图通过 Windows 命令输入来了解我的 PHP 版本,
C:\> php -v但它不起作用。它说php is not recognized as internal or external command。
回答by NullPoiиteя
In command prompt type below
在命令提示符下面键入
set PATH=%PATH%;C:\path\to\php
Where C:\path\to\php is the folder where your php.exefile is located. After this run
其中 C:\path\to\php 是您的文件所在的php.exe文件夹。在这次运行之后
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
Windowsicon
第 1 步- 单击
Windows图标
Step 2- Click on the
Settingsicon
第 2 步- 单击
Settings图标
Step 3- Click on
System
第 3 步- 单击
System
Step 4- Click on
About
第 4 步- 单击
About
Step 5- Click on
System info
第 5 步- 单击
System info
Step 6- Click on
Advanced system settings
第 6 步- 单击
Advanced system settings
Step 7- Click on
Environment variables...
第 7 步- 单击
Environment variables...
Step 8- Select
Pathrow and then clickEdit
步骤 8- 选择
Path行,然后单击Edit
Step 9- Click
Newand then clickBrowse, then in the next panel which will open you need to select the folder you want in thePath. For the initial premise of this guide i will add the folderC:\Users\NewFolderInPath?Note: Replace your PHP installed path(e.g:
C:\Program Files\php) with the above path ?.
步骤 9- 单击
New然后单击Browse,然后在将打开的下一个面板中,您需要在Path. 对于本指南的初始前提,我将添加文件夹C:\Users\NewFolderInPath?注意:将您的 PHP 安装路径(例如:)替换
C:\Program Files\php为上述路径 ?。
Step 10- Click
OKand click everyOKbutton you will encounter to close every previous windows.
第 10 步- 单击
OK并单击OK您会遇到的每个按钮以关闭之前的每个窗口。
回答by shivam gupta
You just need to find out where is your PHP folder.
您只需要找出您的 PHP 文件夹在哪里。
- If you are using XAMPP or WAMP then you will see a php folder.
- You just need to go into the php folder using your cmd using command
- 如果您使用 XAMPP 或 WAMP,那么您将看到一个 php 文件夹。
- 您只需要使用 cmd 使用命令进入 php 文件夹
cd \xampp\php (FOR XAMPP)
cd \wamp\php (FOR WAMP)
cd \xampp\php(用于 XAMPP)
cd \wamp\php(用于 WAMP)
- And then just type in this command
- 然后只需输入此命令
php -v
php -v
- Then you will see something like
- 然后你会看到类似的东西
PHP 5.6.11 (cli) (built: Jul 9 2015 20:55:40) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
PHP 5.6.11 (cli) (built: Jul 9 2015 20:55:40) 版权所有 (c) 1997-2015 The PHP Group Zend Engine v2.6.0, 版权所有 (c) 1998-2015 Zend Technologies
回答by S.K.Paul
- First open your cmd
Then go to php folder directory, Suppose your php folder is in xampp folder on your c drive. Your command would then be:
cd c:\xampp\phpAfter that, check your version:
php -v
- 首先打开你的cmd
然后转到php文件夹目录,假设您的php文件夹在c盘的xampp文件夹中。您的命令将是:
cd c:\xampp\php之后,检查您的版本:
php -v
This should give the following output:
这应该给出以下输出:
PHP 7.2.0 (cli) (built: Nov 29 2017 00:17:00) ( ZTS MSVC15 (Visual C++ 2017) x86 ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
PHP 7.2.0 (cli) (built: Nov 29 2017 00:17:00) ( ZTS MSVC15 (Visual C++ 2017) x86 ) 版权所有 (c) 1997-2017 The PHP Group Zend Engine v3.2.0, 版权所有 (c) 1998 -2017 Zend 科技
I have uploaded a youtube video myself about checking the version of PHP via command prompt in Bangla: https://www.youtube.com/watch?v=zVkhD_tv9ck
我自己上传了一个关于通过孟加拉语命令提示符检查 PHP 版本的 youtube 视频:https: //www.youtube.com/watch?v=zVkhD_tv9ck
回答by CB Shrestha
Go to c drive and run the command as below
转到c盘并运行如下命令
C:\xampp\php>php -v
C:\xampp\php>php -v
回答by beerwin
It is most likely that php is not in your specified path.
很可能 php 不在您指定的路径中。
Try to issue the php command with the full path, for example:
尝试使用完整路径发出 php 命令,例如:
C:\> "C:\Program Files\php\php.exe" -v
C:\> "C:\Program Files\php\php.exe" -v
Please note, that this is just an example, your php installation might be in a different directory.
请注意,这只是一个示例,您的 php 安装可能位于不同的目录中。
回答by Kavya Hanumantharaju
xampp control panel->shell->type php-v you get the version of php of your xampp installed
xampp control panel->shell->type php-v 你得到你安装的xampp的php版本
DB(mariadb/mysql)version type localhost/phpmyadmin in url click enter click on sql type select version(); enter to get the mysql or mariaDb version
DB(mariadb/mysql)version type localhost/phpmyadmin in url click enter click on sql type select version(); 输入获取mysql或mariaDb版本
回答by uchedotphp
For Beginners to anything php, it is usually stored in the C:/ path folder of your PC (My Computer).
对于任何 php 的初学者,它通常存储在您的 PC(我的电脑)的 C:/ 路径文件夹中。
==On Windows==
1.Click Start Menu button
2.Type cmdand press enter to select the first program/application that responds to your search result.
A black window terminal will appear, this is known as a Command Line Interpreter
3.In the Terminal Window (Application) Type cd c:and press enter
4.Now type php -vand press enter
==在Windows上==
1.单击开始菜单按钮
2.键入cmd并按回车键选择第一个响应搜索结果的程序/应用程序。
将出现一个黑色窗口终端,这称为命令行解释器
3.在终端窗口(应用程序)中键入cd c:并按 Enter
4.现在键入php -v并按 Enter
and viola there you'll have the current php version that is installed in your machine
中提琴在那里,您将拥有安装在您机器上的当前 php 版本
回答by Adnan Khan AdDY
Easy Method is: Just copy the file cmd.exe from c:/windows/system32/ and paste it to C:\xampp\php\ and run it, when the cmd opens type " php -v " without quotes and hit enter... you will get your php version.. thank you
简单的方法是:只需从 c:/windows/system32/ 复制文件 cmd.exe 并将其粘贴到 C:\xampp\php\ 并运行它,当 cmd 打开时键入“ php -v ”不带引号并按回车键。 ..你会得到你的php版本..谢谢
回答by Sarthak Raval
Step 1 : Open CMD
Step 2 : Go to C:/xampp/php or htdocs path:/
step 3 : Type "php -v "
Result php version
第 1 步:打开 CMD 第 2 步:转到 C:/xampp/php 或 htdocs 路径:/
第 3 步:键入“php -v”结果 php 版本
回答by Vishal Kumar Sahu
For me, the PHP path traversed from php5.6.25(or php7) installation folder, through wamp folder, bin and php...
对我来说,PHP路径是从php5.6.25(或php7)安装文件夹,经过wamp文件夹,bin和php...
C:\wamp64\bin\php\php5.6.25>
C:\wamp64\bin\php\php5.6.25>


