Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下将我重定向到 google.com
Hello!!! <?php echo 'ouch!'; header('Location: http://www.google.com'); ?>
这不应该因为在发送标题之前输出文本而不起作用吗?
不,除非您在重定向之前刷新输出,否则它将始终重定向
Hello!!! <?php echo 'ouch!'; flush(); //This will cause an error on the next line and stop the page from redirecting header('Location: http://www.google.com'); ?>
不会重定向,但会生成有关已发送标头的错误