如何设置UTF-8编码的PHP文件 [英] How to set UTF-8 encoding for a PHP file
问题描述
我叫一个PHP脚本:
<一个href=\"http://cyber-flick.com/apiMorpho.php?method=getMorphoData&word=kot\">http://cyber-flick.com/apiMorpho.php?method=getMorphoData&word=kot
块引用>这显示以纯文本的一些数据:
CzÄĹÄmowy:rzeczownik
Przypadek:dopeĹniacz
Rodzaj:ĹźeĹski
Liczba:mnoga正如你在正确的地方的字符看到有如此灌木丛。我想要做的是在某种程度上显示此让人们在浏览器中正确的UTF-8字符看看。
您可以封装它HMTL标签和在元UTF-8编码设置,但是因为这个脚本接收到的数据进行进一步的处理,我不希望使用任何HTML标记,它应该是纯文本的结果集
那么,有没有一种方法来告知浏览器这个文件是UTF-8,而无需使用meta标签?
PS。文件是EN为UTF-8 codeD,如果我手动更改字符编码在我的浏览器为UTF-8会显示OK,但我想acomplish是不需要的人这样做。
解决方案头('内容类型:text / plain的;字符集= utf-8');
I have a PHP script called :
http://cyber-flick.com/apiMorpho.php?method=getMorphoData&word=kot
That displays some data in plain text:
Cz��� mowy: rzeczownik Przypadek: dope�niacz Rodzaj: şe�ski Liczba: mnoga
As you can see in place of proper chars there are so "bushes". What i would like to do is display this in a way so that people see in browser proper UTF-8 characters.
You can encapsulate it in HMTL tags and set in meta UTF-8 encoding, but because the data received from this script will be processed further I don't want to use any HTML tags, it should be only plain text result set.
So is there a way to inform browser that this file is UTF-8 without using meta tags?
PS. File is encoded in UTF-8 and if I manually change charset encoding in my browser to UTF-8 it displays ok, but what I want to acomplish is people to not be required to do so.
解决方案header('Content-type: text/plain; charset=utf-8');
这篇关于如何设置UTF-8编码的PHP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!