I recieve data from post form and want do store it in MySQL the code line for handling the input is:
$tekst = $_POST["tekst"];
$tekst = htmlentities($tekst, ENT_QUOTES, ENT_HTML5, "UTF-8");
When I run this I get the error message: Warning: htmlentities(): charset `ENT_HTML5' not supported, assuming iso-8859-1 in savepage.php on line 14 index.php?id=1&ret=1 1
How do I overcome the warning?
You got that error because you used the flag ENT_HTML5
which appeared only in PHP5.4.0 .
As you can confirm this from the official documentation :
5.4.0 The constants ENT_SUBSTITUTE, ENT_DISALLOWED, ENT_HTML401, ENT_XML1, ENT_XHTML and ENT_HTML5 were added.
If your only goal is to overcome that error, then you can simply let the flags of the htmlentities()
function not set. Let PHP to treat them by default.
I mean, change this:
$tekst = htmlentities($tekst, ENT_QUOTES, ENT_HTML5, "UTF-8");
To:
$tekst = htmlentities($tekst, "UTF-8");
An other option, is to set replace them with other flags supported by PHP5.3.0 , such as:
ENT_COMPAT
: Default. Encodes only double quotes
ENT_IGNORE
: Ignores invalid encoding instead of having the function return an empty string. Should be avoided, as it may have security implications.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.