phpinfo();
will give you the web version of the php
php -v
will give you the CLI version (command line interface) of the php
depending on the webserver you use (the most common are apache and nginx) change the way to load the module or php version for the web. This is what allows to have several versions of php running at the same time.
To change only the CLI version:
echo "* Switching CLI PHP to 7.2..."
sudo update-alternatives --set php /usr/bin/php7.2 > /dev/null
taken from link
If you want to change both versions globally (apache and cli) you can download and install the repo script ( link )
of the same repo to install php 7.2:
echo "* Installing PHP 7.2..."
sudo apt-get install -y php7.2 php7.2-common php7.2-cli > /dev/null
echo "* Installing PHP 7.2 extensions..."
sudo apt-get install -y php7.2-bz2 php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-soap php7.2-sqlite3 php7.2-tidy php7.2-xml php7.2-xsl php7.2-zip php-redis > /dev/null
echo "* Installing additional PHP extensions..."
sudo apt-get install -y php-memcache php-memcached > /dev/null
link