Jump to content

What's the difference between these two functions?


Mr Chris

Recommended Posts

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 & &#039;Tarzan&#039;";
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";

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.