A PHP snippet that has run without issue for weeks suddenly logs a deprecation notice, with no code changes on your own end.
⚡ Quick Fix (TL;DR)
The Culprit: mb_convert_encoding() with 'HTML-ENTITIES' as the target encoding was deprecated in PHP 8.2. Any server that upgrades its own PHP version will start logging this notice on unchanged code that previously ran silently.
The Fix: Replace it with mb_encode_numericentity(), which does the same job – converting non-ASCII characters to numeric HTML entities – without triggering the deprecation. Avoid htmlspecialchars() as a substitute here if the content contains real HTML tags you still need parsed afterward, since it would escape those tags too.
$convmap = array(0x80, 0x10FFFF, 0, 0xFFFFFF);
$safe_content = mb_encode_numericentity($content, $convmap, 'UTF-8');
Rather not untangle this yourself? Our Done-For-You team handles exactly this kind of thing, start to finish.
See DFY options →
Was this helpful?
Thanks for the feedback!
Tagged in :