I think I have a better solution, to switch the php version in Homestead (I am using version 8 currently) running following lines of code switches the default php version.
sudo update-alternatives --set php /usr/bin/php7.1
sudo update-alternatives --set phar /usr/bin/phar7.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.1
sudo update-alternatives --set phpize /usr/bin/phpize7.1
sudo update-alternatives --set php-config /usr/bin/php-config7.1
Above line will switch the php version from any version to version 7.1 (Homestead 8 comes with php 7.3 by default).
Do remember to reload web-server (apache or nginx) after making this change.
July 2020 UPDATE: In newer versions of homestead to change php version there are aliases like php71
php72
php73
php74
etc. to easily
swith between versions