Mr Chris Posted May 25, 2010 Share Posted May 25, 2010 Hello, Bit confused? Anyone tell me which is the better to use between: htmlspecialchars_decode AND html_entity_decode and also htmlspecialchars AND html_entities Seem to do the same things. What are the differences in each case and which in each case is the best to use as they seem to end in the same result? Thanks <? //Know html_entities & html_entity_decode can take 3 Parameters //And htmlspecialchars_decode & htmlspecialchars take 2 //In each case what is the best to use? // htmlspecialchars_decode AND html_entity_decode $string1 = "Jane & 'Tarzan'"; echo "Using htmlspecialchars_decode:" .htmlspecialchars_decode($string1, ENT_QUOTES)."<br />\n"; echo "Using html_entity_decode:" .html_entity_decode($string1,ENT_QUOTES)."<br />\n"; // htmlspecialchars AND html_entities $string2 = "Jane & 'Tarzan'"; echo "Using htmlentities:" .htmlentities($string2,ENT_QUOTES)."<br />\n"; echo "Using htmlspecialchars:" .htmlspecialchars($string2, ENT_QUOTES)."<br />\n"; ?> Link to comment https://forums.phpfreaks.com/topic/202867-whats-the-difference-between-these-two-functions/ Share on other sites More sharing options...
cags Posted May 27, 2010 Share Posted May 27, 2010 You should use the decoding method that corresponds to the encoding method which you used. The manual states quite clearly what the difference is between the two encoding methods. htmlentities Link to comment https://forums.phpfreaks.com/topic/202867-whats-the-difference-between-these-two-functions/#findComment-1064042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.