--- "James M. Luedke" <[EMAIL PROTECTED]> wrote: > I was wondering if someone may be able to explain why the following > code will not work... I have been scratching my head for a few hours > now and I am stumped. > > <?php > header("Location: http://someplace.com"); > > if( ! headers_sent()) > header("Location: http://somplaceelse.com"); > ?> > > So I would expect this piece of code to direct me to somplace.com.
Your second call to header() uses the same header name, thus that header (Location) is replaced with http://someplaceelse.com. The code works as expected. If you expected your conditional statement to fail, you are probably confusing headers_sent() to mean something like have_i_used_the_header_function_yet(). The headers are all sent at once, regardless of how many times you use header(). This function helps people avoid receiving the headers already sent warning, and as long as you have no output yet in your script, you should still be able to make changes to the headers. Hope that helps. Chris ===== Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php