Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars
Description
When passing a valid encoding to htmlentities(), but that is not supported, a warning is displayed, and an empty string is returned. This contrasts with the behavior when the encoding is not recognized, where PHP defaults to UTF-8, and returns something non empty.
Example
<?php
var_dump( htmlentities("Café & 'quotes' and € euro", ENT_QUOTES, 'Big5') );
// '', empty string
?>
Alternatives
- Check that the used encoding is supported.
Changed Behavior
This error may appear following an evolution in behavior, in previous versions. See