PHP显示特殊字符 [英] PHP Display Special Characters

查看:107
本文介绍了PHP显示特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从xml文件中输出文本£3.99每M²时,浏览器显示 每个M²的价格为£3.99 .XML文件为UTF-8格式.我想知道如何修复 这个.

When i output the text £3.99 per M² from an xml file,browser displays it as £3.99 per M².XML file is in UTF-8 format.I wonder how to fix this.

推荐答案

请确保您正在输出UTF-8.该转换听起来像您的来源是UTF-8,但您是在告诉浏览器期望其他内容(Latin1?).您应该发送一个指示浏览器UTF-8即将到来的标头,并且您应该具有正确的元标头:

Make sure you're outputting UTF-8. That conversion sounds like your source is UTF-8, yet you're telling the browser to expect something else (Latin1?). You should send a header indicating to the browser UTF-8 is coming up, and you should have the correct meta header:

 <?php
 header ('Content-type: text/html; charset=utf-8');
 ?>
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 </head>
 <body>
 <?php echo "£3.99 per M²"; ?>
 </body>
 </html>

这应该可以正常工作.

这篇关于PHP显示特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆