Php Cookie创建错误
可能重复:Php Cookie创建错误,php,wordpress,Php,Wordpress,可能重复: 我在我的wordpress主题的主页上收到了标题,并且发送了错误。我的职能是: function LoopCokiee() { if(isset($_COOKIE['PozCounter'])) { setcookie("PozCounter", ++$_COOKIE['PozCounter'], time()+3600); } else { setcookie("PozCounter",
我在我的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().'-->'
?>
我该怎么办?任何帮助都可以,谢谢 在发送标题之前不要使用任何输出在数据已发送到web浏览器以进行输出之后,不能设置cookie。在此之前,您必须设置Cookie。请看这一条:谢谢您,michal,但我不明白我只是将我的函数放在doctype info之前。如果您完全确定在头之前没有输出任何内容,则可能是文件开头的UTF-8字节顺序标记。在我粘贴的链接中,您有关于如何检查和删除BOM表的信息。我刚刚修复了它。它是关于BOM的。谢谢你,Michal。我刚刚把cokiee create函数放在了我的头上。php
index.php中有输出的东西吗?如果是的话,那就是问题的原因。我做到了。除了BOM的问题外,什么都没有。我刚拿到。非常感谢。
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