Here are solutions:
Step1: Add Ondrejs PPA Repo
sudo add-apt-repository ppa:ondrej/php
Step2: sudo apt-get update
Step3: Install PHP 7.1
Lets stop our server first, then install PHP 7.1.
sudo service apache2 stop
sudo apt-get install php7.1 php7.1-common
Step4: We’ll also install some extra packages for our PHP installation – these are needed for Laravel and Composer!
sudo apt-get install php7.1-curl php7.1-xml php7.1-zip php7.1-gd php7.1-mysql php7.1-mbstring
Step5: remove php7.0
sudo apt-get purge php7.0 php7.0-common
sudo shutdown -r now
Step6: sudo a2enmod php7.1
Step7: sudo service apache2 restart
Now your php upgraded successfully you check using command php -v