Maybe have a look here? What does dpkg -l php*
give you?
It should be safe to remove (not purge) all php5* packages, if you want to go back you can install it again. (Note though, that you will need an extra repository like this one because Debian 9 stretch only includes php7.)