需要重定向url而不使用函数头

Ric*_*ves 4 php url-redirection

我需要将我的页面重定向到另一个,但我不能使用该header功能,有没有其他方法可以做到这一点?

我需要做的是这样的事情:

if (test){
   ---do something---
   redirect
} else {
   return false
}
Run Code Online (Sandbox Code Playgroud)

谢谢

Par*_*ait 19

if (test){
   ---do something---
   die("<script>location.href = 'http://www.google.com'</script>");
} else {
   return false;
}
Run Code Online (Sandbox Code Playgroud)


Dee*_*epu 5

元重定向

    if (test){
       //do something
       echo '<META HTTP-EQUIV="Refresh" Content="0; URL=yourpage.php">';//This causes the browser to open the new page after 0 seconds, i.e immediately.
    }  else {
       return false;
    } 
Run Code Online (Sandbox Code Playgroud)