I will explain how to install php7.1 on Debian Jessie using deb.sury.org
Install packages required for third party repositories over https
$ apt-get install apt-transport-https lsb-release ca-certificates wget
Get the repository key
$ wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
Add the repository
$ echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
Update package list
$ apt-get update
Install php 7.1
$ apt-get install php7.1-cli
You should be able to use php from cli
[email protected]:~# php -v PHP 7.1.1-1+0~20170120094658.14+jessie~1.gbp69d416 (cli) (built: Jan 20 2017 11:53:59) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.1-1+0~20170120094658.14+jessie~1.gbp69d416, Copyright (c) 1999-2017, by Zend Technologies
It is very common that you will need some more packages like xdebug, xml, mysql
apt-get install php7.1-xdebug php7.1-xml php7.1-mysql php7.1-mbstring
This tutorial use info from deb.sury.org