You need to switch between PHP 5.6 and 7.1 on your Ubuntu 16.x, without any docker/vm bs?
Here is one of several ways tpo do it.
Sometimes you can’t just upgrade Ubuntu to >=16 which ships a LAMP with PHP 7 by default .
As a temporary solution you can upgrade your old LAMP to PHP 7 whilst keeping PHP 5.x available.
I needed a bash script to capture some repository info from a different folder in variables.
Dr. Google was helpful again and so I came up with this example script.