I built a PHP 5 app back in ~2007 that's still in active use today. My hosting provider emailed me at some point saying that they would force-upgrade the server to PHP 8 for security reasons.
It took less than 2 hours of effort to update all of the code to work with the latest version.
Much of your php 5 code will run in 7 and 8 and if it's 5.2+ most will run. Your php 4 code would run. Your php 3 code would.