Switching between php versions

Check current version

ls -lha /etc/alternatives/php

Output:

/etc/alternatives/php -> /usr/bin/php7.0

Current version is 7.0

Switch to version

sudo ln -sf /usr/bin/php5.6 /etc/alternatives/php

Check current version

ls -lha /etc/alternatives/php

Output:

/etc/alternatives/php -> /usr/bin/php5.6

Current version is 5.6

php --version

PHP 5.6.40-7+ubuntu18.04.1+deb.sury.org+1 (cli) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies