Re: [OUTPUT BUFFER] - problems with redirects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A rewrite of the entire site would be needed in order to fix. So, I guess
you are saying as best options for workaround are

- use the ob_ functions to work around.
- stick output buffer on or high

so best case scenario using ob_ functions as a cleaner method aside from
rewriting the code?

seems silly btw that you can't output html and just have it redirect
whenever you want it to at any point in the page.

Thanks, T


On Thu, Aug 19, 2010 at 4:22 PM, Nathan Rixham <nrixham@xxxxxxxxx> wrote:

> Tristan wrote:
>
>> So, I'm have this site where all this code was developed and the logic
>> sits
>> in different plugins throughout a template. So, html is output and then
>> hits
>> one of these plugins. Plugins do some processing and then hit a
>> header(location...) redirect.
>>
>> So, problem is they developed code with these header redirects and now we
>> there's too much html being output so we get the buffer errors
>>
>> Cannot modify header information - headers already sent by (output started
>> at
>>
>> /home/carma/templates_c/carma^0^31^811^%%E2^E22^E22E607D%%carma%3Amenu.php:138)
>>
>> to fix we have to up the buffer ouput in the php to something really high.
>>
>> So, as far as I know this is not good coding practice and upping the
>> output
>> buffer is really masking the problem.
>>
>> Is there another way to work around this like another way to do redirects
>> that won't cause these buffer probs?
>>
>
> Hi Tristan,
>
> Really it's a nudge from your code that it needs refactored - however to
> answer your question..
>
> - there is no way to do an HTTP redirect once headers are sent
> - you can use an html meta refresh, or javascript redirect - if the output
> is going to be HTML viewed in a browser.
>
> caveat, obviously robots and the like will still see the incorrect output -
> it's a hack not a fix.
>
> The other approach is to use ob_start() and related functions to capture
> all the code generated without any output being sent to the browser, this
> should allow you to send the header down when needed.
>
> Certainly wouldn't just knock output buffering right up high to work around
> it if I was you.
>
> Best,
>
> Nathan
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux