Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.