可能重複發送標題:
PHP error: Cannot modify header information – headers already sent
Headers already sent by PHPPHP不能更改頭信息 - 已經
這是我的代碼:
<html>
<body>
<?php
if($country_code == 'US')
{
header('Location: http://www.test.com');
}
else
{
header('Location: http://www.test.com/');
}
?>
<script language="JavaScript" type="text/javascript"></script>
</body>
</html>
沒有空間之前<?php
或af ter ?>
我已經嘗試將HTML代碼和Javascript放在PHP下面,但是這樣會使它無法跟蹤點擊頁面。
你已經發送''... – Dan
它是一個.html文件或PHP文件。如果它是一個html頁面,瀏覽器不能知道php。您的源代碼必須在.php文件中執行php行。 – hakiko