Header redirect fails

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
powrtoch
Forum Newbie
Posts: 5
Joined: Thu Nov 05, 2009 9:55 am

Header redirect fails

Post by powrtoch »

I know this first thing you think is "no output to the browser before the header function". There isn't any. No tags, no spaces, no line breaks, nothing. I don't even have a "headers already sent" error displaying. For some reason though, the redirect simply does not work, and my script indicates that headers are getting sent anyway. I go to the page, and I just get a blank page with the undirected url up top. Is there some php configuration variable that could cause this to fail?

Here is my ENTIRE script.

Code: Select all

<?php
    $a = headers_sent();
    header("Location: http://google.com");
    $b = headers_sent();
    echo "$a<br />$b";
    exit();
?>
The output is:
1
1

Obviously the first one should not be a 1. Any thoughts? I'm going nuts here.
davegmpd
Forum Newbie
Posts: 14
Joined: Tue Oct 27, 2009 9:42 am
Location: London

Re: Header redirect fails

Post by davegmpd »

You could try a combination of the Firefox "Live HTTP Headers" plugin (to see what's going back and forth) and also potentially this:

Code: Select all

 
ob_end_clean();
 
See if that makes any difference.

Are you sure there's not output ;)

Dave
Post Reply