使用UTF-8-BOM编码的PHP会话 [英] PHP session with UTF-8-BOM encoding

查看:110
本文介绍了使用UTF-8-BOM编码的PHP会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用UTF-8-BOM编码创建了一个php页面.我想使用这种编码,因为我有一些使用本地语言的内容,并且确实显示了正确的内容,所以我需要使用UTF-8-BOM编码.

I have created one php page with UTF-8-BOM encoding. I want to use this encoding because I have some content which are in my regional language, and do display it properly i need to use UTF-8-BOM encoding.

现在,我想在此页面上使用会话,但它会抛出已设置的标题错误.

Now I want to use session with this page but it is throwing error of headers already set.

那么我有什么办法可以同时使用两者.

So is there any way i can use both together.

如果我仅尝试使用UTF-8,则以区域格式显示数据不会出现问题.

If I am trying to use UTF-8 only I am not getting problem displaying data in regional format.

请参阅附件图片

推荐答案

字节顺序标记"是文件开头的3个字节的序列,使其与PHP几乎不兼容,因为该脚本应该仅包含 PHP代码必须以<?php标记开头.

The "Byte Order Mark" is a sequence of 3 bytes that a file begins with, making it pretty much incompatible with PHP, because a script that is supposed to contain only PHP code must start with the <?php tag instead.

很显然,这并不是说整个事情都不起作用,但是涉及发送HTTP标头(很多)的任何事情都会自动损坏.

Obviously, it's not like the whole thing doesn't work at all, but anything that involves sending HTTP headers (which is A LOT) automatically gets broken.

会话使用cookie-通过标头传输-无法使用.
重定向到另一页-Location标头-无法正常工作.
动态生成的下载-下载的文件本身将被破坏.

Sessions use cookies - transferred via headers - won't work.
Redirecting to another page - the Location header - won't work.
Dynamically generated downloads - the downloaded file itself will be broken.

对不起,但是您必须放弃BOM,并想出另一种方式来处理特定于区域设置的数据(出于任何原因,我只能假定正在使用另一个字符集).

Sorry, but you'll have to give up on BOM and figure another way to handle your locale-specific data (which I can only assume is using another charset for whatever reason).

这篇关于使用UTF-8-BOM编码的PHP会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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