vim ~/.bashrc
alias phpchange=change_php
change_php(){
CURRENT_PHP_VERSION=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d"." 2>/dev/null)
echo "Current PHP Version is ".$CURRENT_PHP_VERSION;
sudo a2dismod php$CURRENT_PHP_VERSION;
sudo a2enmod php$1;
sudo update-alternatives --set php /usr/bin/php$1
sudo service apache2 restart
}
and then run phpchange 7.0 // to switch to 7
make sure you need to have that version installed