Htmlspecialchars output empty

Using htmlspecialchars and htmlentities causes empty exits from elements such as character β„’and even single quotes '. Obviously, this is completely useless, however, outputting data without the use of html characters leads to this character as for. Any reason this is happening?

here is the code causing the problem:

<p>
<?php 
    echo nl2br(htmlspecialchars($aboutarray[0]['about_us'], ENT_COMPAT, "UTF-8")); 
?>
</p>
+5
source share
1 answer

This string is not encoded in valid UTF-8 encoding. It may be in a different encoding, such as UTF-16, or maybe just contain some binary garbage that does not match any format.

, , "UTF-8" htmlspecialchars(), , "UTF-8". PHP.

. :

htmlspecialchars($aboutarray[0]['about_us'], ENT_COMPAT, "UTF-8")

To:

htmlspecialchars($aboutarray[0]['about_us'], ENT_COMPAT|ENT_SUBSTITUTE, "UTF-8")

:

htmlspecialchars($aboutarray[0]['about_us'], ENT_COMPAT|ENT_IGNORE, "UTF-8")

: ENT_IGNORE . . - . , ENT_IGNORE.

, UTF-8... , .

; , .

+13

All Articles