you can if you use a javascript redirect or an html meta refresh ~ish.
not really that silly tbh if you think about an HTTP message is like this:
Headers
...
MessageBody
.....
the redirect is a header, so it get's sent through *before* the body,
and the headers tell the client how to process the messagebody (or
indeed whether to process it or just do something else).
consider an html page the same as a gif or a zip, it's just a chunk of
computer data that gets sent in one, you wouldn't expect to be able to
redirect somebody whilst they're halfway through downloading a big zip
would you?
but yeah ob_** functions, this way you're catching the entire
MessageBody (your html) before sending anything to the client, which
then let's you send headers followed by body in your own time.
Best,
nathan
Tristan wrote:
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php