So I know this
string HTML entities ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset") [, bool $double_encode = true ]]] )
is supposed to encode HTML entities but I can’t seem to get it to work. So basically what I’m trying to ask is, can someone please explain to me how to use this?
The page on PHP’s website isn’t making much sense to me.
Advertisement
Answer
You can use below example
$str = "Jane & 'Tarzan'"; echo htmlspecialchars($str, ENT_COMPAT); // Will only convert double quotes $str = 'I love "PHP".'; echo htmlspecialchars($str, ENT_QUOTES); // Converts double and single quotes