开发者

CodeIgniter - strange output issue

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.


Does it happen to all views in a particular controller? Maybe you have an echo in a constructor.


This is a subheader of chunked encoded (https://en.wikipedia.org/wiki/Chunked_transfer_encoding) answer. Simplest way to disable chunking is using 1.0 version of HTTP:

$this->output->set_header("HTTP/1.0 404 Not Found");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜