10

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:

enter image description here

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

Anyone have any ideas?

Running this on Windows 10 64 bit OS.

user3574492
  • 6,225
  • 9
  • 52
  • 105
  • Maybe you're looking at two separate instances of PHP on the machine. What version do you see at the top of the page when you navigate to a page with this code only: ` – BeetleJuice Aug 29 '17 at 12:28
  • You need to find where to change PHP CLI version, it is different settings for which PHP version to run in Apache and witch to run from command line – rypskar Aug 29 '17 at 12:30
  • @RiggsFolly can you please link the related question, because I couldn't find anything relevant and you have marked this as a duplicate. – Agil Dec 02 '18 at 08:53
  • if you need to change php in cli you only need change: system’s PATH variable C:\wamp64\bin\php\php5.6.38 to C:\wamp64\bin\php\php7.2.10 and restart you computer. – Darkcoder Dec 24 '19 at 20:36

2 Answers2

14

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

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 2
    There's an option in WAMPManager: `right click / Tools / Change PHP CLI version` – Winand Aug 07 '18 at 05:55
  • @Winand Yes, as of WAMPServer 3.1.1 this is so – RiggsFolly Aug 07 '18 at 08:33
  • 1
    though there's such a note here https://github.com/midnight-coding/WampServer-PHP-CLI-Version-Changer `This selection currently changes the CLI version that the WampServer's scripts use, not what your scripts use when called from the command line` – Winand Aug 07 '18 at 08:54
  • @Winand Hi, thats not an official tool. Use at your own risk. Stuff in config file changes and there is no reason to believe that whoever that is written by, will keep up to date with those changes – RiggsFolly Aug 07 '18 at 09:12
  • 3
    @RiggsFolly. You are correct. Being the author of the [WampServer-PHP-CLI-Version-Changer](https://github.com/midnight-coding/WampServer-PHP-CLI-Version-Changer) batch script I would like everyone to know that it is not an official WampServer tool. WampServer is such a great tool if you develop on windows. Over the years I have tried XAMPP, WAMP, WampDeveloper Pro & Vagrant, all with their own pro's and con's. WampServer's ability to quickly and easily change between Apache, PHP & MySQL versions is brilliant. My script eases the pain in **specifically** changing the PHP CLI version number. – midnight-coding Dec 30 '18 at 07:47
  • I had same problem changing the version, but when tried what @Winand mentioned my Wamp Server changed the PHP version immediately and no need to restart the computer. – Codeparl Aug 11 '22 at 05:33
5

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!

theduck
  • 2,589
  • 13
  • 17
  • 23
Darragh Blake
  • 238
  • 1
  • 6