For CentOS 7 PHP 5 is likely the default/global/system PHP installation and you’re better off upgrading instead of removing.
Here’s how it’s done but I think this entire thread will help you …
PHP 7.2 is the default/global version that comes with CentOS 8, similar to how PHP 5 is default for CentOS 7. Notice how 7.2 was upgraded to 7.4 and how add-on PHP versions and modules install differently than the global version.