PHP,重定向到另一个页面

How in a PHP script do I redirect to another page? I tried header, but this didn't work since before my header() statement is an echo.

This, I do not want to use:

echo "<meta http-equiv='refresh' content='1;URL=?".$link."'>"; 
  • Use ob_start() to delay the printing, and use header(), or
  • Redirect using Javascript, this can be done anywhere in the page, or
  • Rewrite your code so that you know early on, before anything is printed, whether you want a redirect.

You would want to do the following:

header('Location: http://www.someURL.com');

But this must be done before anything is dropped to the output steam. Also you would not want to use

echo "<meta http-equiv='refresh' content='1;URL=?".$link."'>"; 

As it would force the browser to reload your page, effectively rendering it useless if the user is trying to click a link or type something just as it refreshes.