PHP奇怪字符之前的£符号? [英] PHP Strange character before £ sign?

查看:323
本文介绍了PHP奇怪字符之前的£符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,当我在表单上的文本字段中输入£时,我会得到一个 £76756687的奇怪字符?

& pound; )



作为示例字符集(对于表单页面和HTML电子邮件),您可以使用:



< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/ >



也就是说,是否有一个很好的理由,用户必须输入货币符号?将它作为静态文本项或下拉到文本字段的左边是更好的主意吗? (如果我说的是屁股,你使用的是自由形式的textarea或summat,可随意忽略。)


For some reason i get a £76756687 weird character when i type a £ into a text field on my form?

解决方案

As you suspect, it's a character encoding issue - is the page set to use a charset of UTF-8? (You can't go wrong with this encoding really.) Also, you'll probably want to entity encode the pound symbol on the way out (&pound;)

As an example character set (for both the form page and HTML email) you could use:

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

That said, is there a good reason for the user to have to enter the currency symbol? Would it be a better idea to have it as either a static text item or a drop down to the left of the text field? (Feel free to ignore if I'm talking arse and you're using a freeform textarea or summat.)

这篇关于PHP奇怪字符之前的£符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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