<body>
<p>We hope to see you again..</p>
<?php header('Location: http://something/com'); ?>
</body>
怎麼回事?我複製w3school的語法php的標題不工作btw html?
<body>
<p>We hope to see you again..</p>
<?php header('Location: http://something/com'); ?>
</body>
怎麼回事?我複製w3school的語法php的標題不工作btw html?
必須在發送任何實際輸出之前調用header(),或者通過普通的HTML標記,文件中的空行或PHP發送。使用include或require函數或其他文件訪問函數讀取代碼,並在調用header()之前輸出空格或空行是非常常見的錯誤。使用單個PHP/HTML文件時存在同樣的問題。
你可以做這樣的事情:
<?php
$message = "We hope to see you again..";
header('Location: http://something/com?msg='.$message);
exit;
?>
而在重定向頁面回聲$_GET['msg'];
無空格之前和赫德()函數顯示您的消息。標題在任何輸出之前。
你需要把你的代碼統計該頁
的像
<?php
header("Location: http://www.example.com/"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
參考http://php.net/manual/en/function.header.php –
「*我複製的語法從w3school *「。這是你的問題。查看[w3fools.com](http://w3fools.com)。 – h2ooooooo