[英]redirect to a page without Warning: Cannot modify header information - headers already sent by
so this is driving me crazy I understand the error. 所以这让我发疯了我理解错误。 But I am trying to redirect to the page regardless.
但我试图重定向到页面无论如何。 meaning : if condition = 1 => redirect to this page... or redirect to another.
含义:if condition = 1 =>重定向到此页面...或重定向到另一个页面。 any other alternatives?
还有其他选择吗?
Have you tried using <?php ob_start(); ?>
你尝试过使用
<?php ob_start(); ?>
<?php ob_start(); ?>
at the start of the page? <?php ob_start(); ?>
在页面的开头?
You need to make sure nothing is being sent to the browser before you send the redirect header. 在发送重定向标头之前,您需要确保没有任何内容发送到浏览器。 One possible solution (although quick and dirty) is using output buffering, so at the start of the page put
一种可能的解决方案(虽然快速和脏)使用输出缓冲,因此在页面开始时放置
<?php
ob_start();
// any code you need to check whether to redirect
// note that output from between the ob_start()
// and the ob_end_clean() won't be sent to the user
ob_end_clean();
and then do your redirection checks and redirection. 然后执行重定向检查和重定向。 Remember, don't let anything output.
记住,不要让任何输出。 So no echos, etc.
所以没有回声等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.