Table of contents Home page
$s = 'Obelix & Co.'; echo htmlentities($s) . "\n"; // The & character will be converted to &
$s = 'String with double (") and single (\') quote'; echo htmlentities($s, ENT_QUOTES) . "\n"; // Both types of quotes are converted (to " and ' respectively)
mb_internal_encoding('UTF-8'); $s = "\xfcber"; // String encoded in ISO-8859-1 echo htmlentities($s, ENT_QUOTES, 'ISO-8859-1'); // The u with diaeresis is correctly converted to ü, even though the string is encoded in ISO-8859-1 instead // of in the internal encoding (UTF-8).
$s = 'a > b && a < c'; // This string already contains some HTML character entities echo htmlentities($s, ENT_QUOTES, 'UTF-8', FALSE); // Because the fourth argument has the value of FALSE, the already encoded less-than and greater-than signs won't be // encoded again.