I have installed php 5.6 and and php 7.1 on my Ubuntu 16.04
I know with Apache as my web server, I can do
a2enmod php5.6 #to enable php5 a2enmod php7.1
You can use the below script to switch between PHP version easily I have included phpize configuration too.
https://github.com/anilkumararumulla/switch-php-version
Download the script file and run
sh switch.sh