It is likely that upgradepkg is your best bet. It fdoes both things that you mention. It first installs the new package and then erases the directories where the old packages resided. upgradepkg has some very helpful options. That cover every situation that the very familiar rpm program also has. If you were compiling from source, I would say just uninstall with pkgtool, but since you say you wish to upgrade one Slack package to another, it seems easier (to me) to do the operation with one step instead of two.
you shouldn't have to pass any options to upgradepkg since you only have three packages.
installpkg will not erase the old instances of php, and your other packages. It will your sysem full of old references to the packages that you had first (in addition to all the new folders). This can sometimes create a mess. Best of luck.