<?php
ob_start();
echo "<body><p>Hello "
if ($condition) {
header( "Location: http://www.google.com/" );
exit;
}
echo " World!</p></body>";
ob_end_flush();
?>
When $condition
is true I get this:
<body>Hello
What I want is when $condition
will be true then go to Google!!!
I don't know what is happening, can you explain or give me a solution!?
Thanks.
Just add
ob_end_clean();
before the header call.Everything should work, just put an
;
after echo "<body><p>Hello
" and you will be fine..If I were you, I would have started what might go wrong first then do the processing.
An example