2

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.

BrynJ
  • 8,322
  • 14
  • 65
  • 89

3 Answers3

1

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.

Community
  • 1
  • 1
justinl
  • 10,448
  • 21
  • 70
  • 88
  • I'm confident I haven't got any trailing whitespace (I've checked and I'm following the recommended convention of omitting the closing php tag). I've added the UTF-8 encoding to my htaccess file but again no success. I've updated my question with a new discovery however. – BrynJ Dec 16 '10 at 11:26
0

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");
Milaza
  • 111
  • 2
  • 4
0

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

rrrhys
  • 654
  • 5
  • 18
  • No - I've got some custom routing for all requests through one controller in the linked site, but it's only on the 404 page that the issue exists. – BrynJ Dec 16 '10 at 11:14