If you have two php versions (e.g. PHP7.2 and PHP 5.6 ) installed in your ubuntu system.
Apache:-
sudo a2dismod php7.2
sudo a2enmod php5.6
sudo service apache2 restart
Command Line:-
sudo update-alternatives --set php /usr/bin/php5.6
sudo update-alternatives --set phar /usr/bin/phar5.6
sudo update-alternatives --set phar.phar /usr/bin/phar.phar5.6
sudo update-alternatives --set phpize /usr/bin/phpize5.6
sudo update-alternatives --set php-config /usr/bin/php-config5.6
Switch from PHP 5.6 to PHP 7.2 =====>
Apache:-
sudo a2dismod php5.6 sudo a2enmod php7.2 sudo service apache2 restart
Command Line:-
sudo update-alternatives --set php /usr/bin/php7.2 sudo update-alternatives --set phar /usr/bin/phar7.2 sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2 sudo update-alternatives --set phpize /usr/bin/phpize7.2 sudo update-alternatives --set php-config /usr/bin/php-config7.2
Switch from PHP 7.2 to PHP 5.6 =====>
Apache:-sudo a2dismod php7.2
sudo a2enmod php5.6
sudo service apache2 restart
Command Line:-
sudo update-alternatives --set php /usr/bin/php5.6
sudo update-alternatives --set phar /usr/bin/phar5.6
sudo update-alternatives --set phar.phar /usr/bin/phar.phar5.6
sudo update-alternatives --set phpize /usr/bin/phpize5.6
sudo update-alternatives --set php-config /usr/bin/php-config5.6