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

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -