Is there a way to redirect to another page in php without using header()? I can't use header() because I am outputting some stuff first to the page. I've considered using Javascript's window.location but I'm using an if statement in php so is there any way in php to go to another page without using header()? Thanks in advance.
2条回答 默认 最新
dongzhang3482 2015-03-13 14:02关注I can't use header() because I am outputting some stuff first to the page.
You shouldn't dismiss using
header(). Usingheader()is still achievable by using output buffering.For example:
<?php ob_start(); //start the buffer echo "This is some output"; //Output data ob_clean(); //Erase the buffer content header('Location: http://google.com'); //Redirect user本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报