简体   繁体   English

重定向到没有警告的页面:无法修改标题信息 - 已发送的标题

[英]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.

相关问题 如何删除警告无法修改标头信息-标头已发送 - How to remove warning Cannot modify header information - headers already sent by 警告:无法修改标头信息-标头已发送 - Warning: Cannot modify header information - headers already sent by 警告:无法修改标题信息 - 标题已在 wordpress 中发送 - Warning: Cannot modify header information - headers already sent by in wordpress 无法修改标题信息-标题已发送 - Cannot modify Header Information - headers already sent 无法修改标头信息 - 标头已发送 - Cannot modify header information - headers already sent 无法修改标头信息-标头已由发送 - Cannot modify header information - headers already sent by 无法修改已发送的标头信息标头 - Cannot Modify Header Information Headers Already Sent 关于警告的奇怪错误:无法修改标题信息-没有空格PHP时已经发送的标题 - Strange error regarding Warning: Cannot modify header information - headers already sent by when there is no white space PHP Wordpress提要:PHP警告无法修改标题信息-标题已发送 - Wordpress Feeds: PHP Warning Cannot modify header information - headers already sent 为什么我没有收到“警告:无法修改标头信息-标头已经发送”的信息,我希望得到它? - Why I'm not getting a 'Warning: Cannot modify header information - headers already sent by' as I expected to get one?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM