[TriLUG] Odd website behaviour

Igor Partola igor at igorpartola.com
Tue Apr 9 15:41:57 EDT 2013


Some more things I thought of:

You could try turning error reporting on/off, setting the error reporting
level explicitly, etc.

Another possible issue here is that the echo'ing happens before headers are
sent (as per your warning), and one of the headers it is now unable to send
is the Content-Type header. In that case the browser will get the default
content type and try to interpret the image as perhaps text/plain,
text/html, or something more exotic.

Also, it is possible that some underlying library is not using error
reporting at all, but throws an error (how great is PHP, with two different
ways to report errors?!), or just does a print statement somewhere.

Lastly, and this is a really tricky one, but is there a possibility that a
newline got introduced somewhere? I have seen this trip things up:

  <?php
  // PHP code
  ?>

Where the final ?> is followed by a few linebreaks. Then if this file is a
library, and is included before your actual code, a bunch of newlines will
be output before the image output starts.

A good way to get around this is to omit the final ?>. In PHP it is
optional, and omitting it prevents this exact issue.

Hope that helps.

Igor



More information about the TriLUG mailing list