php - How to use a href while using htmlspecialchars -
let's if have code
$text = "please visit <a href="http://example.com">site</a>." $text = htmlspecialchars($text); echo $text;
so it's output please visit <a href="http://example.com">site</a>.
want it's output
please visit site. there way see if it's href somthing? thanks.
only escape url itself:
$text = 'please visit <a href="' . htmlspecialchars('http://example.com') . '">site</a>.'
notice switching between single , double quotes.
Comments
Post a Comment