产生如下错误: Warning: Cannot modify header information - headers already sent by (output started at c:\apache group\apache\htdocs\etao\includes\header.php:2) in c:\apache group\apache\htdocs\etao\lcupd.php on line 306 不能实现.我的意思如下,请问如何实现: if(true){ redirect to true.php } else{ redirect to false.php }
Warning: Cannot modify header information - headers already sent by (output started at c:\apache group\apache\htdocs\etao\includes\header.php:2) in c:\apache group\apache\htdocs\etao\lcupd.php on line 306
不能实现.我的意思如下,请问如何实现:
if(true){
redirect to true.php
}
else{
redirect to false.php
}
header("location:1.php");
} else {
header("location:2.php");
}注意之间不要有输出。
if(true)
{
echo "<meta http-equiv='refresh' content='0;URL=文件地址'>";
}else{
echo "<meta http-equiv='refresh' content='0;URL=文件地址'>";
}
?>也可以这样
<?
if(true)
{
?>
<script language="javascript">
self.location="转向文件";
</script>
<?
}else{
?>
<script language="javascript">
self.location="转向文件";
</script>
<?
}
?>
<?php
.
.
if(true){
echo "<script language=javascript>window.location = 'true.php';</script>";
}
else{
echo "<script language=javascript>window.location = 'false.php';</script>";
}
.
.
?>
方法二:echo "<script>window.location =\"$PHP_SELF\";</script>";
方法三:echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=index.php\">";
<FORM ACTION="<? echo "$PHP_SELF"; ?>" METHOD="POST">