可以在包含BOM元素的Unicode UTF 8中保存我的网站上的标题位置吗? [英] Can saving in Unicode UTF 8 including BOM elements break my header location on my site?

查看:112
本文介绍了可以在包含BOM元素的Unicode UTF 8中保存我的网站上的标题位置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用标题位置并没有问题。然后我添加了一种语言(法语),并且必须将我的文件保存为包含BOM元素的Unicode UTF 8 ...



现在我的标题位置不再起作用了。奇怪的是没有显示错误信息...

所以我更新了我的函数来显示一个自制的错误信息......见下面

 函数redirect_to($ location ='index.php'){
//代码已到达,error_reporting测试

#flush();

if(headers_sent()){
echo'Debug:will send location header',$ location,$ unsetVariableTriggeringWarning;
die('无法发送位置标题(不再)');
}
else {
header('Location:'。$ _ SESSION ['base_url']。$ location);
die();
}

}

现在我收到了错误信息:

$ p $ Debug:将发送位置标题access.php redirecto = accountcannot发送位置标题(不再有)

但是没有任何东西被打印出来,没有HTML,没有PHP,没有任何东西。所以我最好的猜测是当我转换为Unicode utf8时,肯定会发生一些事情。所以我转回去,但仍然错误仍然存​​在......



任何帮助,非常感谢。

解决方案

PHP引擎不会消耗脚本中的<?php 之前的BOM,因此它将被发送出去照常。删除BOM。


I use header Location across my site and there was no problem. I then added a language (French) and had to save my files in Unicode UTF 8 including BOM elements...

Now my header location doesn't work anymore...the weird part being that there is no error message displayed...

So I updated my function to display a self made error message...see below

function redirect_to( $location = 'index.php'){
// code reached, error_reporting test

#flush();

if (headers_sent()) { 
    echo 'Debug: would send location header ', $location, $unsetVariableTriggeringWarning;
    die('cannot send location header (anymore)');
}
else {
  header('Location: '.$_SESSION['base_url'].$location);
  die();
}   

}

And I do get the error message now:

Debug: would send location header access.php?redirecto=accountcannot send location header (anymore)

But nothing has been printed out yet, no HTML, no PHP, no nothing. So my best guess was when I converted to Unicode utf8, there must of been something that happened. So I switched back, but still, the error persists...

Any help, much appreciated.

解决方案

The PHP engine does not consume the BOM that would be before the <?php in the script, so it will be sent out as usual. Remove the BOM.

这篇关于可以在包含BOM元素的Unicode UTF 8中保存我的网站上的标题位置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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