Question

How can I make the deprecated functions to work in PHP's latest version? I don't want to change the alternate function of it in each and every page, it's highly impossible in the maintenance project which I have. So please let me know if there is a way to make the deprecated functions to work.

Was it helpful?

Solution

If you really can't change the code you've got, how about creating wrappers for the new functions that have the same specification as the deprecated function? So in other words, you create a new function that calls the deprecated function but takes in the arguments of the old function. Might work...

OTHER TIPS

You have to fix them to use the corresponding API that replaces the deprecated API. The deprecated API is deprecated for a reason.

The right thing to do is fix your code. PHP4 reached end of life 4 years ago and is not supported any more. I'm sure there exists a large number of dangerous bugs in PHP4 which will never be fixed.

The situation you are in now is called technical debt. You will need to repay the debt sooner or later.

You can add to your technical debt by reimplementing the old functions yourself, but that will make the code even harder to maintain in the future. Everything you do in your code base right now will probably need to be reimplemented from scratch once you've fixed the deprecated code. You can therefore choose to continue adding functions to the deprecated code (and increase the debt) or bringing the code into 2012 and repaying your debt entirely before going ahead and adding anything new.

Writing code is not hard or time-consuming. You should be able to find streamlined ways to fix the deprecated code. I'm sure you and your team may be able to solve most or all the deprecated code in a couple of days if you are focused on that only. In comparison, consider how much time it will take to implement even the simplest functions in a spaghetti-like code base.

Deprecated functions are deprecated for a reason. You should either keep your distribution of PHP at an older release version, or upgrade and update the functions that are marked as deprecated. You should do the right thing and update your functions to those used in the newer versions of PHP. PHP4 stopped development in 2008, which means you really should've upgraded a long time ago.

If you're on Linux, Regexxer might be of some use to update all your files in one go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top