4

I have been using PHP for a very long time and for some reason migrating to a new server has caused a White Screen of Death. Obviously it must be because of a version difference. I have been using the same output buffer pattern for years.

Typically...

ob_start();
?>
    //HTML...
<?php
$output = ob_get_clean();
ob_flush();

return $output;

Recently I had discovered some problems in my normal/newer versions of PHP (5.4+ On my WAMP I think) while returning HTML sections and passing them around between views (I use MVC). They were displaying entirely to the screen and not being saved in the buffer at all. I found out that I needed a necessary flag in my ob_start() to let it know that buffers can be removed.

Like so ob_start(null, 0, PHP_OUTPUT_HANDLER_REMOVABLE);

However now that my page is live and not on WAMP the entire page now breaks and shows full whitescreen. I have all error reporting turned on and still nothing. Nothing showing up in logs, etc. So I have done a large series of echo "test"; die; to see at what line it is breaking and sure enough all is well when I remove the buffered sections that pass finished HTML blocks between views.

I need to figure out how to properly have my sections returned.

GoreDefex
  • 1,461
  • 2
  • 17
  • 41
  • 1
    is display_error on, and do you have error_reporting(E_ALL); ?? – Philip G Nov 25 '14 at 11:55
  • 1
    You don't need ob_flush(); at all here, ob_get_clean(); closes the output buffer... – Paul Norman Nov 25 '14 at 12:10
  • oh my god @Paul Norman .... thanks I appreciate it more than you know. This was a "teaching an old dog new tricks" mistake. I have known for a long time that it closes the buffer and calls both ob_get_contents and ob_end_clean. However a few years ago I was having errors that required me call both get_clean and flush. – GoreDefex Nov 25 '14 at 12:16
  • Are you able to submit an answer so I can +1 it :) Appreciate the help – GoreDefex Nov 25 '14 at 12:16

1 Answers1

1

You don't need ob_flush() in this situation because ob_get_clean() has already closed the output buffer.

Paul Norman
  • 1,621
  • 1
  • 9
  • 20