We are running XAMPP with PHP 7.0 because our new products requires PHP 7.
But there are old project which use functions like mysql_connect
, etc. Those are removed in PHP 7.0.
So is there way to easily change PHP versions in XAMPP.
Note : Please don't suggest to upgrade old project to compatible with new versions because I am not in a position to do it because that decisions I can't get as a developer (just an employee).
You don't need to waste your time with this configurations just use MAMP :)
MAMP have a PHP version selection feature on interface.
You can download and install two different xampps like I do: (first is php7 second is php5)
and if you don't want to do that, I suggest you use wamp and change versions like shown here.
You can download whatever versions of PHP you need and place them into their own directories, e.g.
c:\php5\
c:\php7\
All you need to do is tell your web server (Apache) which version of PHP to use, which you do by loading the appropriate module. In Apache you can do this by finding the file
httpd.conf
and then editing the appropriate line:LoadModule php7_module c:\php7\libphp7.so
You'll have to figure out the correct paths of course - this is just for illustration.
Save
httpd.conf
and restart your server. Note, if you don't restart it, the changes won't take effect.There's no GUI switch to be able to do this, you need to edit the
.conf
file and then restart Apache. Doing this only takes a couple of seconds and you could even comment out a version so "switching" only takes a couple of keystrokes, e.g.Use PHP 5:
Use PHP 7:
You do not need multiple versions of XAMPP, or to dual boot, or use a different machine, or any of the other "solutions" that have suggested convoluted workarounds. The OP wants to use XAMPP and tell it which version of PHP to use. This is the quickest and most efficient way of doing it, and only requires one XAMPP installation.
Edit 1-Nov-2017: Apparently some people are saying there's no
.so
files on Windows. The answer I gave was adapted from how I have things set up on my Mac (which does use.so
files instead of.dll
). The principle of the answer however is still exactly correct. You are using Apache's configuration file,httpd.conf
to specify where the PHP module (.so
or.dll
) is located on your system. So the only difference for Windows would be the file name and/or path location. The answer I've given is also correct for a vanilla installation of Apache/PHP (without XAMPP at all).