例如,这是我的PHP代码:
<?php
if($country_code == 'US')
{
        header('Location: http://www.test.com');
}
else 
{
        header('Location: http://www.test.com/');
}
?>我正在尝试使用Javascript代码进行跟踪,它必须在</body>标签之上。
我尝试过将PHP代码与HTML结合的不同方法,我也尝试过将其单独放在PHP下面,举个例子:
<html>
<head></head>
<body>
    <?php
     ?>
<script></script>
</body>
</html>我得到的最远的结果是,它跟踪了点击,但没有重定向,给了我这个错误:
`Warning: Cannot modify header information - headers already sent by`感谢您的建议和帮助,谢谢!
发布于 2012-12-16 22:57:52
您必须尝试执行以下操作才能进行跟踪:
<?php
if($country_code == 'US')
{
        header('Location: http://www.test.com/?us=yes');
}
else 
{
        header('Location: http://www.test.com/?us=no');
}
?>然后在您的索引页面中检查us参数的值。此外,您还应该注意到在函数之前没有任何输出,以使警告无效:
Warning: Cannot modify header information - headers already sent by
https://stackoverflow.com/questions/13902366
复制相似问题