Forum Moderators: coopster
<?
$str = "A 'quote' is <b>bold</b>";
$output = htmlentities($str, ENT_QUOTES);
$output1 = htmlentities($str, ENT_NOQUOTES);
$output2 = htmlentities($str, ENT_COMPAT);
$output3 = htmlentities($str);
echo "output is $output<br>output1 is $output1<br>output2 is $output2<br>output3 is $output3<br><br>";
$output = htmlspecialchars($str, ENT_QUOTES);
$output1 = htmlspecialchars($str, ENT_NOQUOTES);
$output2 = htmlspecialchars($str, ENT_COMPAT);
$output3 = htmlspecialchars($str);
echo "output is $output<br>output1 is $output1<br>output2 is $output2<br>output3 is $output3<br>";
>?
Produces:
output is A 'quote' is <b>bold</b>
output1 is A 'quote' is <b>bold</b>
output2 is A 'quote' is <b>bold</b>
output3 is A 'quote' is <b>bold</b>
output is A 'quote' is <b>bold</b>
output1 is A 'quote' is <b>bold</b>
output2 is A 'quote' is <b>bold</b>
output3 is A 'quote' is <b>bold</b>
Can anyone explain what is going on here?
Thanks - Jim
Have you looked at your source code? The character entities will display the characters correctly on your web page, but in your source code they will still be character entities.
Just a thought. Alternatively, if all you want to convert are apostrophes, try str_replace().
dc