Below are the steps to install PHP 7.2 and its related most important modules. Currently as of now PHP 7.2 is the latest stable version and we recommend you to install this.
Step 1: As always first update Ubuntu
sudo apt-get update && apt-get upgrade
Step 2: To add PHP repository you need to first install this
sudo apt-get install python-software-properties
Step 3: Add PHP repository from ondrej
sudo add-apt-repository ppa:ondrej/php
Step 4: Update your package list
sudo apt-get update
Step 5: Install PHP 7.2
sudo apt-get install php7.2
Step 6: Verify PHP 7.2 installed Successfully
php -v
Step 7: Install Related and important PHP modules
sudo apt-get install php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml