我们使用PHP 7.0运行XAMPP,因为我们的新产品需要PHP 7。
但也有一些旧的项目使用mysql_connect等函数。这些在PHP 7.0中被删除。
那么,是否有一种方法可以轻松地在XAMPP中更改PHP版本?
注意:请不要建议将旧项目升级到与新版本兼容,因为我无法做到这一点 这些决定是我作为开发人员(只是一名员工)无法得到的。
我们使用PHP 7.0运行XAMPP,因为我们的新产品需要PHP 7。
但也有一些旧的项目使用mysql_connect等函数。这些在PHP 7.0中被删除。
那么,是否有一种方法可以轻松地在XAMPP中更改PHP版本?
注意:请不要建议将旧项目升级到与新版本兼容,因为我无法做到这一点 这些决定是我作为开发人员(只是一名员工)无法得到的。
当前回答
我需要做同样的事情,所以我谷歌了一下,结果发现堆栈溢出,而OP也有同样的问题……所以我的发现…我尝试从不同的方向重命名文件,我的结论基本上是它花了我太长时间。所以我最终只是从这里安装了第7版:
https://www.apachefriends.org/index.html (在尝试xampp之前杀死服务并退出)
当被问到在哪里放置目录名称时,就像这样(给它一个不同的名字):
and
DONEZO !现在只要确保在来回交换之前杀死服务并退出,你就有2个无菌的XAMPP环境可以玩。
万岁!现在我真的可以去工作了!
其他回答
你不需要在这个配置上浪费时间,只需要使用MAMP:)
MAMP在界面上有PHP版本选择功能。
在命令提示符窗口(cmd.exe)中运行此命令。
set PATH=C:\xampp\php;%PATH%
根据安装PHP 7的位置进行更改。
我知道这是旧的帖子,但我想分享有一个库仍然运行mysql_connect()在PHP 7。 它通过覆盖实际函数来工作(mysql_connect()被工作在这个库上的mysqli_connect()覆盖)。
我从这个视频https://www.youtube.com/watch?v=Eqd-jJu4sQ4中找到的
希望能有所帮助
这可能是这个问题最不具技术性的答案,但也是最容易实现的。
如果你有两个驱动器,比如C:和D:,你可以在两个不同的php版本的驱动器上安装XAMPP的单独实例。这花了我不到10分钟的时间,是最不容易出错的。
我只是为xampp-control.exe创建了两个桌面快捷方式,并以它们的php版本命名快捷方式。我希望这能帮助像我这样喜欢快速而肮脏的解决方案的人。
您可以有两个不同版本的XAMPP。
Download those files from https://www.apachefriends.org/download.html and install into a directory of your choice, for example in C:\5.6.31\xampp and C:\7.1.18\xampp. After every installation go to installed directory (ex. C:\5.6.31\xampp, C:\7.1.18\xampp) and start the "setup_xampp.bat" and you should see something like this. You can make shortcuts of "xampp-control.exe" on your desktop (right click on "xampp-control.exe" Send to -> Desktop) and rename shortcuts for ex. "xampp 5.6.31" and "xampp 7.1.8". Start XAMPP control panel with double-click on "xampp-control.exe" or previously created shortcut and start Apache and MySQL servers. To test installiation open your browser and type 127.0.0.1 or localhost in the location bar. You should see XAMPP start screen. Do not open more then one XAMPP control panel. XAMPP uninstall? Simply remove the "xampp" Directory. But before please shutdown the apache and mysql. That's all. You can use different php versions opening corresponding XAMPP control panel.