1. Download the required version of PHP from https://www.php.net/downloads.php. For PHP7+, you can download the Thread Safe version. For older PHP, try the Non Thread Safe version.

  2. Create another folder in C:\xampp for this version of PHP apart from the existing C:\xampp\php. E.g., C:\xampp\php74.

  3. Copy the downloaded version’s file into this folder

  4. Create php.ini in this folder by duplicating php.ini-development

  5. Edit php.ini and uncomment the line extension_dir="ext"

  6. Uncomment required extensions in the same php.ini. Refer to existing PHP version’s ini file to see which extensions to uncomment. For example, uncomment the line extension=mysqli.

  7. In the XAMPP Control Panel, click Config button for Apache and select httpd-xampp.conf

  8. Add the following lines to the (end of the) file:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    
    ScriptAlias /php74 "C:/xampp/php74"
    Action application/x-httpd-php74-cgi /php74/php-cgi.exe
    <Directory "C:/xampp/php74">
        AllowOverride None
        Options None
        Require all denied
        <Files "php-cgi.exe">
            Require all granted
        </Files>
    </Directory>
    
    <Directory "C:\xampp\htdocs\project-folder">
        <FilesMatch "\.php$">
            SetHandler application/x-httpd-php74-cgi
        </FilesMatch>
    </Directory>
    
    

    You can add a project-folder entry for each website that needs to be configured for this version of PHP

  9. In httpd-xampp.conf file, comment the line SetEnv PHPRC "\\xampp\\php" (Comment character is #)

  10. Restart Apache

For other methods to configure multiple PHP versions, see this Stack Overflow thread.