我们使用PHP 7.0运行XAMPP,因为我们的新产品需要PHP 7。

但也有一些旧的项目使用mysql_connect等函数。这些在PHP 7.0中被删除。

那么,是否有一种方法可以轻松地在XAMPP中更改PHP版本?

注意:请不要建议将旧项目升级到与新版本兼容,因为我无法做到这一点 这些决定是我作为开发人员(只是一名员工)无法得到的。


当前回答

简单和最容易的步骤

Install xampps whatever php version you want. Rename xampp folder in C:\xampp to C:\xampp74 Download and install another xampps like I do: (first is php7 second is php8) Now you have two different xampp with different php version Now whenever you want to change you just nned to follow stop Apache and mysql and Quit xampp Rename folder to xampp an change other xampp folder with it's version name to remember Again Start the Apache and mysql (some time it can't rename then restart and try)

其他回答

使用这个php切换器

你可以通过vhost配置控制php版本到任何你想要的项目。

在命令提示符窗口(cmd.exe)中运行此命令。

set PATH=C:\xampp\php;%PATH%

根据安装PHP 7的位置进行更改。

你可以像我一样下载并安装两个不同的xampps:(第一个是php7,第二个是php5)

如果你不想这样做,我建议你使用wamp并像这里显示的那样更改版本。

我使用unisserver。

它内置了这个功能。

http://www.uniformserver.com/

就是这么简单。

统一服务器是一个免费的轻量级WAMP服务器解决方案。小于24MB,模块化设计,包括最新版本的Apache2, Perl5, PHP(在PHP53, PHP54, PHP55或PHP56之间切换),MySQL5或MariaDB5, phpMyAdmin或Adminer4。不需要安装!没有注册尘埃!打开行李,发动吧!

它甚至可以用u盘运行。有cron仿真,支持perl, mariaDB,几个版本的Mysql, filezilla服务器和其他一些东西。

我需要做同样的事情,所以我谷歌了一下,结果发现堆栈溢出,而OP也有同样的问题……所以我的发现…我尝试从不同的方向重命名文件,我的结论基本上是它花了我太长时间。所以我最终只是从这里安装了第7版:

https://www.apachefriends.org/index.html (在尝试xampp之前杀死服务并退出)

当被问到在哪里放置目录名称时,就像这样(给它一个不同的名字):

and

DONEZO !现在只要确保在来回交换之前杀死服务并退出,你就有2个无菌的XAMPP环境可以玩。

万岁!现在我真的可以去工作了!