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

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

那么,是否有一种方法可以轻松地在XAMPP中更改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.

其他回答

我只是想分享我的新发现:https://laragon.org/docs/index.html

我刚用了一个小时,看起来很不错。

你可以添加和切换PHP版本, 它有一键安装Wordpress, laravel等 它自动创建vhosts与每个应用程序的名称(例如。appname.test) 你可以选择你当前的htdocs文件夹作为WWW根文件夹 您只需添加其他PHP版本,将它们提取到文件夹中,并从列表中选择它们 它会在每次更改后自动重载apache 添加phpMyAdmin就像下载它一样简单,并把它放在{LARAGON_DIR}\etc\apps\phpMyAdmin等…

拉拉贡文档

如何添加另一个PHP版本的Laragon

如何添加phpMyAdmin到Laragon


我和拉拉贡没有任何关系。刚刚在谷歌上找到它,寻找“XAMPP Windows替代品”

您可以有两个不同版本的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.

简单和最容易的步骤

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文件夹(对我几年前发现的phpswitch略有修改)。

将不同的文件夹复制到XAMPP安装中。每个PHP文件夹(活动文件夹除外)接收版本号作为后缀(例如。php_5.6.32)。在所有PHP文件夹中,创建一个文件(PHP_VERSION),其中只包含相应的版本号,因此Script可以获取该信息。但这些都在自述书中描述了。

从PHP7开始,httpd-xamp .conf加载php7ts.dll而不是php5ts.dll。因此,我必须扩展脚本(PHPSwitch.php),以遵循相同的方法重命名这些配置文件。

    $renameCur = new PHPSwitch_Rename($currInst['path'], $this->_cfg['phpInstallationsPath'] . $this->_cfg['phpDirName'] . '_' . $currInst['version']);
    $renameNew = new PHPSwitch_Rename($newInst['path'], $this->_cfg['phpInstallationsPath'] . $this->_cfg['phpDirName']);

    $apache_curent      = $this->_cfg["phpInstallationsPath"]."apache/conf/extra/httpd-xampp.conf";
    $apache_curent_rename   = $this->_cfg["phpInstallationsPath"]."apache/conf/extra/httpd-xampp_".$currInst['version'].".conf";
    $apache_new             = $this->_cfg["phpInstallationsPath"]."apache/conf/extra/httpd-xampp_".$newInst['version'].".conf";
    $apache_new_rename      = $this->_cfg["phpInstallationsPath"]."apache/conf/extra/httpd-xampp.conf";

    $renameCur_apache_conf = new PHPSwitch_Rename($apache_curent, $apache_curent_rename);
    $renameNew_apache_conf = new PHPSwitch_Rename($apache_new, $apache_new_rename);

    $transaction = new PHPSwitch_Rename_Transaction();
    $transaction->add($renameCur);
    $transaction->add($renameNew);
    $transaction->add($renameCur_apache_conf);
    $transaction->add($renameNew_apache_conf);

我知道这是旧的帖子,但我想分享有一个库仍然运行mysql_connect()在PHP 7。 它通过覆盖实际函数来工作(mysql_connect()被工作在这个库上的mysqli_connect()覆盖)。

我从这个视频https://www.youtube.com/watch?v=Eqd-jJu4sQ4中找到的

希望能有所帮助