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'];
    }

}

これは私のローカルでは完全に機能しますが、ホストゲーターの何が問題なのか理解できませんでしたか?

関数を呼び出したとき。

<?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

You cannot set a cookie after data has already been sent to the web browser to output. You must set cookies before this happens or use output buffering.

于 2013-01-31T12:52:34.203 に答える