I need to print an HTML tag on screen as texts (and not in code).
I need the readers to literally read the tag.
What is the best practice to do so ?
print htmlspecialchars('<meta name="copyright" content="© Winston Smith, 1984">');
or
print htmlentities('<meta name="copyright" content="© Winston Smith, 1984">');
or none of the above.
*EDIT I*
I already seen a problem with the character "©" with htmlentities(). This only confirms my doubts - which one is safe to use for all cases - and is there another way to print html tags as text ?
Basically all you really need to make HTML readable as text is:
$out = strtr($input,Array("<"=>"<","&"=>"&"));
htmlspecialchars is basically a subset of htmlentities. htmlentities encodes EVERYTHING that has an entity alternative, namely all the named entities and a handful of codes.
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