Wampserver not changing the PHP version [duplicate]

倖福魔咒の 提交于 2020-01-03 08:47:08

问题


I have Wampserver 3.0.6 32 bit installed and it comes with PHP versions 5.6.25 and 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.

I can test this with running this in the command prompt: 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.

When I visit localhost in the browser it shows the following:

I'm not sure why its still showing php version 5.6.

Anyone have any ideas?

Running this on Windows 10 64 bit OS.


回答1:


The version in your terminal and the version wamp is using may be different.

In a wamp project create a PHP file and put this in it.

<?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

Good luck!




回答2:


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.

It does not have any effect on the version of PHP used in the PHP CLI (Command Line Interface).

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.

See this answer for 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.

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.

(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



来源:https://stackoverflow.com/questions/45939111/wampserver-not-changing-the-php-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!