0

可能重复:
PHP 已发送的标头

我的 wordpress 主题主页上的标题已经发送错误。我的功能像;

function LoopCokiee() {
    if(isset($_COOKIE['PozCounter'])) 
    { 

         setcookie("PozCounter", ++$_COOKIE['PozCounter'], time()+3600); 
    } 
    else 
    { 

         setcookie("PozCounter", 1, time()+3600); 
    } 

    return $_COOKIE['PozCounter'];

}

function LoopCokieeUpdate () {
    $Kuki = $_COOKIE['PozCounter'];
    $Topl = '20'; //wp_count_posts()->publish;

    if ($Kuki > $Topl ) {
        setcookie("PozCounter", 1, time()+3600); 
    } else {
        return $_COOKIE['PozCounter'];
    }

}

这在我的本地功能上非常完美,但我没有理解hostgator有什么问题?

当我调用我的函数时;

<?php 
 LoopCokiee();
 LoopCokieeUpdate();
echo '<!--LoopResults--'.LoopCokiee().'//'.LoopCokieeUpdate().'-->'
?>

出现此错误;

Warning: Cannot modify header information - headers already sent by (output started at /home/igze/public_html/ddddd.com/wp-content/themes/smooth/home.php:1) in /home/igze/public_html/ddddd.com/wp-content/themes/smooth/PozHook/index.php on line 11

Warning: Cannot modify header information - headers already sent by (output started at /home/igze/public_html/ddddd.com/wp-content/themes/smooth/home.php:1) in /home/igze/public_html/ddddd.com/wp-content/themes/smooth/PozHook/index.php on line 11

我应该怎么办 ?任何帮助谢谢。

4

2 回答 2

1

在发送标头之前不要使用任何输出

于 2013-01-31T12:51:44.637 回答
1

在数据已经发送到网络浏览器进行输出后,您无法设置 cookie。您必须在此之前设置 cookie 或使用输出缓冲

于 2013-01-31T12:52:34.203 回答