Reply to Re: "header" call doesn't work before lenghty operation

Your name:

Reply:


Posted by Andy Hassall on 02/18/06 19:56

On Sat, 18 Feb 2006 16:21:57 +0100, "Janwillem Borleffs" <jw@jwscripts.com>
wrote:

>Jerry Stuckle wrote:
>> Won't work. You can't send a header call after ANY output.
>
>Dude, don't judge before trying.

You cannot send an HTTP header after any part of the body has been sent.

In some circumstances you can _call_ header() after _calling_ functions that
generate output, i.e. when you have output buffering on, because the header and
the content go into separate buffers, and PHP sends them out in the right order
when it comes to flushing the buffers and actually starting to send to the
client.

But once content has started to go to the client (i.e. immediately in the
default configuration, or after the first flush in buffered configurations),
you can't send an HTTP header, since there's no way in HTTP to send headers in
the middle of the message body.

Your code from the prior post produces:

Please wait
Warning: Cannot modify header information - headers already sent by (output
started at /home/andyh/public_html/test.php:9) in
/home/andyh/public_html/test.php on line 10

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация