PHP deprecated functions, 8.1 to 8.5: the list, with replacements, for WordPress sites

By CompatNav · Published · Last reviewed · 4 min read

Short answer

A deprecated function still works, but PHP writes a deprecation notice each time it’s called, and a later version usually removes it, which then stops the page. The ones WordPress plugins still call: PHP 8.1 deprecated strftime(), gmstrftime(), strptime(), date_sunrise(), date_sunset() and the mhash*() functions; 8.2 utf8_encode() and utf8_decode(); 8.3 get_class() without arguments and assert_options(); 8.4 lcg_value(), mysqli_ping(), mysqli_kill(), mysqli_refresh() and xml_set_object(); 8.5 curl_close(), curl_share_close(), imagedestroy(), finfo_close(), xml_parser_free() and two aliases. PHP 8.0 removed functions deprecated in 7.x, such as create_function() and each().

Deprecated, then removed

A deprecated function keeps working. PHP adds a notice every time it runs, so the code’s owner knows to change it. Here is strftime() on PHP 8.0 and on 8.1, which deprecated it:

wp-content/plugins/event-dates/event-dates.php

<?php
$timestamp = 1798675200; // 31 December 2026, 00:00 UTC
echo strftime('%Y-%m-%d', $timestamp), "\n";

Output on PHP 8.0.30

2026-12-31

Output on PHP 8.1.34

Deprecated: Function strftime() is deprecated in /var/www/html/wp-content/plugins/event-dates/event-dates.php on line 3
2026-12-31

Same result, plus a line in the log. When a later version removes a function, the first call stops the page with “Call to undefined function”: that is what happened to create_function() and each() in PHP 8.0. Deprecation notice or fatal error explains the difference for a site.

This list covers the deprecated functions that WordPress plugins are likely to call. php.net lists every deprecation of each version, including constants, arguments and rarer extensions (LDAP, Intl, ODBC…): see the links under each heading.

PHP 8.1

From php.net’s PHP 8.1 deprecations:

FunctionUse instead
strftime(), gmstrftime()date() / gmdate(), or IntlDateFormatter::format(); in WordPress, wp_date()
strptime()date_parse_from_format(), or IntlDateFormatter::parse()
date_sunrise(), date_sunset()date_sun_info()
mhash(), mhash_keygen_s2k(), mhash_count(), mhash_get_block_size(), mhash_get_hash_name()the hash_*() functions
odbc_result_all()no replacement
mb_check_encoding() without argumentspass the text to check

More on the most common one: WordPress and PHP 8.1.

PHP 8.2

From php.net’s PHP 8.2 deprecations:

FunctionUse instead
utf8_encode()mb_convert_encoding( $text, 'UTF-8', 'ISO-8859-1' )
utf8_decode()mb_convert_encoding( $text, 'ISO-8859-1', 'UTF-8' )

Both only ever converted from or to ISO-8859-1, which is often not what the code meant: utf8_encode() is deprecated explains the catch.

PHP 8.3

From php.net’s PHP 8.3 deprecations:

FunctionUse instead
get_class(), get_parent_class() without argumentsself::class, parent::class, or get_class( $this )
assert_options()ini_set() / ini_get() with the assert.* settings

The fix for the first: “Calling get_class() without arguments is deprecated”.

PHP 8.4

From php.net’s PHP 8.4 deprecations:

FunctionUse instead
lcg_value()Random\Randomizer::getFloat()
mysqli_ping()nothing: the reconnect feature it served was removed in PHP 8.2
mysqli_kill()the SQL command KILL
mysqli_refresh()the SQL command FLUSH
xml_set_object()pass the object with each handler, as [ $this, 'method' ]
trigger_error() with E_USER_ERRORthrow an exception, or call exit()
session_set_save_handler() with separate functionsa SessionHandlerInterface object

A real finding for the first:

PHP 8.5

From php.net’s PHP 8.5 deprecations. Five of them were clean-up calls: php.net says the objects they close “are freed automatically”, so the call can simply go.

FunctionUse instead
curl_close(), curl_share_close()nothing: remove the call
imagedestroy()nothing: remove the call
finfo_close()nothing: remove the call
xml_parser_free()nothing: remove the call
mysqli_execute()mysqli_stmt_execute()
socket_set_timeout()stream_set_timeout()

The most common one, with the fix for code that still supports PHP 7: curl_close() is deprecated.

Already removed: PHP 8.0

These were deprecated in PHP 7.2, 7.3 or 7.4, then removed in PHP 8.0. Every call is a fatal error:

FunctionDeprecated inUse instead
create_function()7.2an anonymous function: function () { … }
each()7.2foreach
read_exif_data()7.2exif_read_data()
png2wbmp(), jpeg2wbmp(), gmp_random()7.2imagewbmp(), gmp_random_range()
fgetss(), gzgetss(), image2wbmp()7.3strip_tags( fgets() ), imagewbmp()
mbereg*(), mbsplit() and other mb* aliases7.3the same names with mb_: mb_ereg(), mb_split()…
money_format()7.4NumberFormatter::formatCurrency()
get_magic_quotes_gpc(), get_magic_quotes_runtime()7.4nothing: they always returned false
hebrevc(), convert_cyr_string(), restore_include_path()7.4nl2br( hebrev() ), mb_convert_encoding(), ini_restore( 'include_path' )
ezmlm_hash()7.4no replacement

The guides for the first two: create_function() and each(); and get_magic_quotes_gpc().

Find them in your plugins

Your error log shows a deprecated function only when the code that calls it runs: a function used in a monthly export stays invisible for weeks. A check that reads the code finds every call, before you upgrade.

CompatNav, a free plugin on wordpress.org, checks every plugin and theme for the functions on this page, among its 58 checks for PHP 8.0 to 8.5. It reports only what changes between the PHP version your site runs and the one you choose, each finding with the file, the line and the replacement, and skips calls already protected by a PHP version check or function_exists(). It runs on your own server and only reads files. Getting started shows the first scan.

Key takeaways

  • Deprecated: still works, with a notice. Removed: a fatal error at the first call.
  • PHP 8.0 removed functions deprecated in PHP 7.2 to 7.4, such as create_function(), each() and money_format().
  • Five of the PHP 8.5 deprecations are clean-up calls that no longer do anything: the call can simply go.
  • Your error log shows a deprecated function only when the code runs; a code check finds every call before you upgrade.
  • php.net’s pages list every deprecation, including rarer extensions; this list covers the functions plugins are likely to call.

Frequently asked questions

Do deprecated functions break my site?

Not while they’re only deprecated: the function runs and PHP writes a notice to the error log. They break when a later PHP version removes them; every call is then a fatal error.

When will PHP remove these functions?

php.net doesn’t give a date for each one. In the past, PHP removed deprecated functions in its next major version: PHP 8.0 removed the functions in the last table below, deprecated in PHP 7.2 to 7.4.

Is there a list of deprecated WordPress functions too?

Yes, WordPress deprecates its own functions too, with a different message that names a WordPress version. This page is about PHP’s own functions, which change with the PHP version.

Check your own site before you upgrade

CompatNav is a free WordPress plugin. It reads the code of your plugins and themes on your own server and tells you, in plain words, what will break and what will only show notices on the PHP version you choose. It never changes your code. It can’t see problems that only appear while code runs with real data, so a quick check of your site after the upgrade still matters.

Get CompatNav on wordpress.org How it works

Sources

About the code examples: each output is the real output of the code shown, run with the official PHP builds, without a php.ini, with all errors reported and displayed. Only the file path was replaced by a neutral server path.