I got something weird happening here and I can't understand why, on my php 5.2.5 server (Just on Linux ,Windows php servers doesn't have same problem) When I use a POST Form to post the content on an input containing "é" and on the other side I
echo(htmlentities($_POST["myinput"]))
it echos é
But if I echo my
$_POST["myinput"]
simply it shows "é", so this mean my htmlentities doesn't use UTF-8 by default, where can I change the Charset used by htmlentities?
I tried changing it in my php.ini default_charset = "UTF-8", but it won't work either?
Difference between htmlentities() and htmlspecialchars() function: The only difference between these function is that htmlspecialchars() function convert the special characters to HTML entities whereas htmlentities() function convert all applicable characters to HTML entities.
The htmlentities() function converts characters to HTML entities.
htmlspecialchars($str, ENT_QUOTES, "UTF-8")
This is also better at preventing xss than just htmlentities()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With