Thursday, April 1, 2010

htmlentities and htmlspecialchars diff

what is the difference between htmlentities and htmlspecialchars?

htmlentities — Convert all applicable characters to HTML entities

htmlspecialchars — Convert special characters to HTML entities

$str = "PHP interview questions and answers collection is good";

echo htmlentities($str);

// Outputs: PHP interview questions and answers collection is <b>bold</b>

$new = htmlspecialchars("Test", ENT_QUOTES);
echo
$new; // <a href='test'>Test</a>

No comments:

Post a Comment