Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

htmlentities() not returnung expected output

Status
Not open for further replies.

webdev007

Programmer
Sep 9, 2005
168
This is part of a class
this simple function is aiming at using htmlentites.
somewhere I do not see what is wrong because if I test it with for example "<b>xxxxx</b>"
the echoed result is still "<b>xxxxx</b>

<?php
error_reporting(E_ALL);
function CleanPost($str)
{
if (isset ($str) && !empty($str) )
{
return htmlentities($str, ENT_QUOTES);
}
}


// Testing **********

$str=($_POST['url']);

echo CleanPost($str);

?>
 
when you say the "echoed result" are you looking at the source code or the browser rendered results? i suspect you need to be looking at the source code.
 
That is the expected result from htmlentities. The only difference is that the <b></b> wont get parsed by the browser, and so the text in between will not be bold, and you'll be able to see the <b> tags.

Otherwise you'd just get :
xxxxx

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks Both
vacunita, now I got it! not knowing the full extension of the result caused my comfusion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top