How to redirect with header location in php when using ob_start?
问题 <?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. 回答1: Just add ob_end_clean(); before the header call. 回答2: Everything should work, just put an ; after echo " <body><p>Hello " and you will be