Wampserver 不更改 PHP 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45939111/
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
Wampserver not changing the PHP version
提问by user3574492
I have Wampserver 3.0.6 32 bit installed and it comes with PHP versions 5.6.25 and 7.0.10.
我安装了 Wampserver 3.0.6 32 位,它带有 PHP 版本 5.6.25 和 7.0.10。
When I switch from 5.6.25 to 7.0.10 from the server tray icon it does not update the actual php version my pc is using.
当我从服务器托盘图标从 5.6.25 切换到 7.0.10 时,它不会更新我的电脑正在使用的实际 php 版本。
I can test this with running this in the command prompt: php -v
:
我可以通过在命令提示符下运行来测试这个php -v
::
PHP 5.6.25 (cli) (built: Aug 18 2016 11:40:20)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
After restarting wamp services and re opening the terminal multiple times it still shows the same thing.
重新启动 wamp 服务并多次重新打开终端后,它仍然显示相同的内容。
When I visit localhost in the browser it shows the following:
当我在浏览器中访问 localhost 时,它显示以下内容:
I'm not sure why its still showing php version 5.6.
我不知道为什么它仍然显示 php 版本 5.6。
Anyone have any ideas?
谁有想法?
Running this on Windows 10 64 bit OS.
在 Windows 10 64 位操作系统上运行它。
采纳答案by Darragh Blake
The version in your terminal and the version wamp is using may be different.
您终端中的版本和 wamp 使用的版本可能不同。
In a wamp project create a PHP file and put this in it.
在 wamp 项目中创建一个 PHP 文件并将其放入其中。
<?php
phpinfo();
?>
Go to the URL of the PHP file in your browser and that will show you the PHP version the apache server in wamp is using. You can change it using this tutorial. Changing PHP version in wamp
在浏览器中转到 PHP 文件的 URL,它将显示 wamp 中的 apache 服务器正在使用的 PHP 版本。您可以使用本教程更改它。 在 wamp 中更改 PHP 版本
Good luck!
祝你好运!
回答by RiggsFolly
When you switch from 5.6.25 to 7.0.10 using the WAMPServer server tray icon it only updates the version of PHP used under Apache.
当您使用 WAMPServer 服务器托盘图标从 5.6.25 切换到 7.0.10 时,它只会更新在 Apache 下使用的 PHP 版本。
It does not have any effect onthe version of PHP used in the PHP CLI (Command Line Interface).
它对PHP CLI(命令行界面)中使用的 PHP 版本没有任何影响。
The simplest way to control the version of PHP used by the CLI is to write a little batch file that will add the correct folder temporarily to the windows PATH for the duration of the command windows existance.
控制 CLI 使用的 PHP 版本的最简单方法是编写一个小批处理文件,该文件将在命令 windows 存在期间将正确的文件夹临时添加到 windows PATH。
See this answerfor how to do that.
请参阅此答案以了解如何执行此操作。
NOTE: Avoid adding the php folder to the Windows PATH permanantly. As when you want to use a different version of PHP in the CLI you will forget to amend this, and a batch file like suggested in the other answer is so much more flexible.
注意:避免将 php 文件夹永久添加到 Windows PATH 中。当您想在 CLI 中使用不同版本的 PHP 时,您会忘记修改它,而另一个答案中建议的批处理文件则更加灵活。
UPDATE
更新
As of WAMPServer 3.1.1 there is now a menu item that will change the PHP CLI version to any version of PHP that you have installed as an ADDON.
从 WAMPServer 3.1.1 开始,现在有一个菜单项可以将 PHP CLI 版本更改为您作为 ADDON 安装的任何 PHP 版本。
(right click) wampmanager->Tools->Change PHP CLI Version
BUT
但
This only changes the version of PHP that the WAMPServer code will use when running its internal PHP based processes. It does not change the PHP CLI version
这只会更改 WAMPServer 代码在运行其内部基于 PHP 的进程时将使用的 PHP 版本。它不会更改 PHP CLI 版本