本文介绍了CodeIgniter - 奇怪的输出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一个非常奇怪的问题与脚本输出。我有时在输出开始之前得到一个四位十六进制代码,在输出结尾有一个零,例如:

  2fc3 
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0
Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd>
< html>
......
< / html>
0

十六进制数取决于所请求的uri和/或内容。我不使用缓存和输出压缩关闭。我在几个项目上看到了这个问题,每个项目都不同,并且托管在不同的服务器上。



问题的一个例子可以在这里看到:



您可以用任何随机文本替换notfound以查看十六进制代码更改为不同的值。



我使用此模板库 - - 虽然即使绕过库并直接输出,使用echo,我看到同样的问题。



我希望能够解决这个问题,所以一切协助都非常感谢。



strong> [Edit] 我发现删除以下内容:

  $ this-> output-> ; set_header('HTTP / 1.1 404 Not Found'); 

修复问题,但为什么会发生这种情况?标题在任何输出之前设置,实际上我没有得到任何关于设置标题的输出开始后的任何php / ci警告。



谢谢, p>

Bryn。

解决方案

在黑暗中拍摄,但是任何php文件在php标签之前或之后都有前导或尾随的空格?这给我以前的问题。



另一个长镜头是这个问题我张贴了一段时间:



向下滚动页面,看看我是如何解决的。它与我的服务器的默认编码不是UTF-8,因此吐出一些垃圾文本在我生成的html。可能不会帮助,但我想我会把它丢在那里。


I'm seeing a very strange issue with script output. I’m sometimes getting a four digit hexadecimal code before the output begins, and a zero at the end of output - for example:

2fc3
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
......
</html>
0

The hex number varies depending on requested uri and / or contents. I'm not using caching and output compression is off. I've seen this issue on a couple of projects, each very different and hosted on different servers.

An example of the issue can be seen here: http://www.holidayproperties.co.uk/notfound.html

You can substitute 'notfound' with any random text to see the hex code change to different values.

I use this template library - http://codeigniter.com/forums/viewthread/95687 - although even when bypassing the library and outputting directly, using echo, I see the same issue.

I'd love to be able to solve this issue, so all assistance is greatly appreciated.

[Edit] I've discovered that removing the following:

$this->output->set_header('HTTP/1.1 404 Not Found');

Fixes the issue, but why should this be happening in the first place? The header is being set before any output, and indeed I don't get any of the php / ci warnings about setting headers after output has begun.

Thanks,

Bryn.

解决方案

A shot in the dark, but do any of your php files have leading or trailing white space before or after the php tags? This has given me problems in the past.

Another long shot is this question I posted a while back: How to get IE8 to not show my PHP page as blank

Scroll down the page to see how I resolved it. It had to do with the default encoding of my server not being UTF-8, and thus spitting out some garbage text in my generated html. Probably not going to help but I thought I'd throw it out there.

这篇关于CodeIgniter - 奇怪的输出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 11:54
查看更多