Table of contents Home page
$s = 'Obelix & Co.'; echo htmlspecialchars($s) . "\n"; // The & character (a 'special' character in HTML) will be converted to &
$s = 'String with double (") and single (\') quote'; echo htmlspecialchars($s, ENT_QUOTES) . "\n"; // Both types of quotes are converted (to " and ' respectively)
$s = 'a > b && a < c'; // This string already contains some HTML character entities echo htmlspecialchars($s, ENT_QUOTES, '', FALSE); // Because the fourth argument has the value of FALSE, the already encoded less-than and greater-than signs won't be // encoded again. // Note that the value of the third argument (encoding) is unimportant, because all characters that can be // converted by this function are encoded the same in all supported encodings.