Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead
Description
Since PHP 8.2, several pseudo-encodings were dropped from mbstring, including HTML-ENTITIES, which converted characters to and from their HTML numeric/named entity representation.
This functionality overlapped with dedicated, better-maintained functions, and its removal simplifies the mbstring encoding conversion tables. It remains usable until PHP 9, when it will be removed entirely.
Example
<?php
mb_convert_encoding('foo', 'HTML-ENTITIES');
?>
Alternatives
- Use
htmlspecialchars()orhtmlentities()to encode text as HTML entities. - Use
mb_encode_numericentity()/mb_decode_numericentity()for numeric entity conversion.
Related error messages
- handling-qprint-via-mbstring-is-deprecated;-use-quoted_printable_encode-quoted_printable_decode-instead
- handling-base64-via-mbstring-is-deprecated;-use-base64_encode-base64_decode-instead
- handling-uuencode-via-mbstring-is-deprecated;-use-convert_uuencode-convert_uudecode-instead
Changed Behavior
This error may appear following an evolution in behavior, in previous versions. See mb_convert_encoding