开发者

HTML character reference display problems

开发者 https://www.devze.com 2022-12-28 19:04 出处:网络
I\'m currently developing a site in Joomla, and one of the components I\'m using makes use of a PHP file to administer the language. (english.php, spanish.php)

I'm currently developing a site in Joomla, and one of the components I'm using makes use of a PHP file to administer the language. (english.php, spanish.php)

The problem I'm having is that if I use the plain text version of eg. "á", it will show up in the browser tab title ok, but as a in the body of the page. But if I use a character reference (&#22开发者_C百科5;), the reverse happens!

Any ideas?

Thanks

bren


Couple of things:

  • Use htmlentities function for your text

    $my_text = htmlentities($string, ENT_QUOTES, 'UTF-8');

More info about the htmlentities function.

  • Use proper document type, this did the trick for me.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  • Use utf-8 encoding type in your page:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号