Brinkster Knowledge Base

KB Home   /  Support  /  Code Snippets  /   Change php version on windows
Change php version on windows Articles

Changing php versions



We have php 5.6***, 7.0***, 7.1***,7.2*** 7.3, 7.4 and 8.0 available.  You can switch between them by changing it within your web.config file.



https://www.php.net/supported-versions.php

***NOTE: 5.6 is at end of life as well as 7.0-7.2, so we suggest updating any software you use (wordpress for example) so that all plugins/themes/CMS applications are compatible with 7.3-8.0.  You can use the below code to switch between them quickly to check if there are issues.

 

We are keeping 5.6 for now as a large number of sites are incompatible with 7.x an 8.0 and will break completely if we switch.  We have switched the server default php version to 8.0 for security reasons.  If this breaks your site, you can switch back to 5.6 following the steps below.

Check what version you are on by creating a php info script.

 

Within webroot\ create a new file.

Call it phpinfo.php (or anything similar).

Edit and add the following code.

<?php

phpinfo();

?>

And save the file

Browse it and see the version of php, ie yoursite.com/phpinfo.php


How to change php versions

Within the webroot\, Create or edit your web.config file.  If you don’t have any code in there (custom) simply copy the following, (if you have code, make sure to place the “handler” opening and closing within the system.webserver section):



<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<handlers>

           <remove name="PHP-FastCGi" />

           <add name="PHP-FastCGi" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP80\php-cgi.exe" resourceType="Unspecified" requireAccess="Script" />

       </handlers>

</system.webServer>

</configuration>



Edit where it shows C:\PHP80 to match the version you need, 56, 70, 71, 72, 73, 74, 80

scriptProcessor="C:\PHP80\php-cgi.exe


Save it and reload the phpinfo script you created and it will show the new version.  You can then test your code/site to see if it works.  If it gives errors you can switch back to the original version.