Search code examples
phphtmlspecialchars

Html special chars


I am using php. I have a problem with special chars. I have a word for example it's. When i do encode in php side with

return htmlspecialchars($text,ENT_QUOTES,"UTF-8");

it is returning it's it is correct but browser does not decode it. So in browser it the same. Why does not browser decode that?

thanks


Solution

  • I tested in IE 8

    <?php
    $text="It's";
    
    echo htmlspecialchars($text,ENT_QUOTES,"UTF-8");
    echo '<br><br>';
    
    echo htmlspecialchars($text);
    
    ?>
    

    Output:

    It's

    It's

    source Output:

    It&#039;s<br><br>It's
    

    Maybe it's a browser setting???