Jump to content

At my wits end - can you help solve this ob_start/ob_end_clean() puzzle?


DLR

Recommended Posts

Hi, this simple function does not work when ob_end_clean() is included.

function get_header($path,$file) {
ob_start();	
include ($path.$file);
$var = ob_get_contents();

                 //file contents are stored in $var so now we try to clean output buffer

                ob_end_clean();  

                 // this stops the script from working - why?
                 // and if I leave it out and add it at the very end of the script it also stops the whole script from working! why?
                 // and if I leave it out alltogether the script seems to work fine!!!! (but the buffer will keep building up with succesive calls to this function - and must surely create a problem somewhere)

                 return $var;
}

get_header("../client_info/",$_SESSION['header']);

I am not sure why, you would have to turn on error reporting and see what errors come.

 

You can also try this instead:

function get_header($path, $file) 
{
    ob_start();
    include($path . $file);
    return ob_get_clean(); 
}

get_header("../client_info/", $_SESSION['header']);

 

If that does not work, yea turn on error displaying and make sure that error_reporting is set to E_ALL and see what error is coming up.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.