Skip to content

Categories:

php header() not working in opera on mac

Came across this strange behaviour in Opera on Mac.
The php header command was simply ignored and the rest of the page executed normally.
Finally found a solution that calls a javascript redirect if nothing else works.

//==== Redirect… Try PHP header redirect, then Java redirect, then try http redirect.:
function redir($url) {
if (!headers_sent()) {    //If headers not sent yet… then do php redirect
header(‘Location: ‘.$url);

exit;
} else {
//If headers are sent… do java redirect… if java disabled, do html redirect.
echo ‘<script type=”text/javascript”>’;
echo ‘window.location.href=”‘.$url.’”;’;
echo ‘</script>’;
echo ‘<noscript>’;
echo ‘<meta http-equiv=”refresh” content=”0;url=’.$url.’” />’;
echo ‘</noscript>’;
exit;
}
return 1;
}

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Posted in code. Tagged with , , .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.