将PHP中的Web开发从一个版本迁移到另一个版本

Suppose i develop any large web application.

For instance PHP offers string or array functions

Say i'm using "sort" array function

If they deprecate this in newer version. Then it's good to have wrapper(utility) class for this type of functions. So it's very easy to modify at one place.

anyone please advice?

Firstly, I doubt that sort() is ever going to be deprecated. It's pretty fundamental.

In general, it is very rare for functions that are part of the PHP core to be deprecated or removed. When this happens, it is usually for one of three reasons:

  • They are old aliases (e.g. mysqli_fetch() was an alias for mysqli_stmt_fetch(), and was eventually removed) or redundant functions that have already been deprecated for a long time (e.g. call_user_method() which was deprecated in PHP 4.1, but only removed in PHP 7) - in general these are clearly marked and you should avoid them in favour of the recommended alternative.
  • They are associated with removed .ini settings, e.g. set_magic_quotes_runtime(). This is likely to be very rare indeed now, as most of the ini settings that have dedicated functions (as opposed to using ini_set()) are either fundamental (e.g. error_reporting()) or have already been removed/deprecated.
  • They are part of an extension that has been completely removed (which normally means moved to the PECL repository). In this case, the whole functionality is gone, and the best way to handle this is either to manually install the extension or to write a shim that replaces the functions that are removed.

There are a few exceptions to the above, but in general function removal is pretty rare, so wrapping-up the individual functions like this will actually result in more work than simply dealing with removals when they occur. There is also a long period in which a function will be marked as deprecated before it is actually removed, so there is normally plenty of time to deal with the issue.

Furthermore, it is actually pretty easy to deal with removed functions (it is one of the simplest backwards-compatibility breakages to work around). Normally, you can simply detect that the function is missing using function_exists() and if it isn't there, declare your own version. If this is non-trivial you will normally find an example online, where someone has already solved the problem.

[A harder problem is if you suddenly need your application to run on an older PHP version than it was designed for, where functions and syntax may not exist yet. You are strongly advised to pick your minimum supported version carefully before you begin work!]